lib/iron/web/html/element.rb
# Set/get attrs on any method missing calls
Set/get attrs on any method missing calls
Set / get attrs on any method missing calls
def method_missing(method, *args)
      parts = method.to_s.match(/^([a-z0-9_]+)(=?)$/i)
      if parts
        key = parts[1].to_sym
        if parts[2] && args.length == 1
          @attrs[key] = args[0]
          return args[0]
        else
          raise "I think you meant <#{@tag}>.html.#{method} instead of <#{@tag}>.#{method}" if block_given?
          return @attrs[key]
        end
      else
        super
      end
    end
def method_missing ( method , * args ) parts = method . to_s . match ( / ^([a-z0-9_]+)(=?)$ /i ) if parts key = parts [ 1 ] . to_sym if parts [ 2 ] && args . length == 1 @attrs [ key ] = args [ 0 ] return args [ 0 ] else raise "I think you meant <#{@tag}>.html.#{method} instead of <#{@tag}>.#{method}" if block_given? return @attrs [ key ] end else super end end
Set/get attrs on any method missing calls
Set / get attrs on any method missing calls
# We have an attempt to set a missing field... # There really is no method...
method
args