Method: Tableling::Model#field

Defined in:
lib/tableling/model.rb

#field(name, options = {}, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/tableling/model.rb', line 22

def field name, options = {}, &block
  if field = @fields.find{ |f| f.name.to_s == name.to_s }
    return field
  end
  # TODO: do not add field if it's already there
  Field.new(name, @field_options.merge({ :modules => @field_modules }).merge(options), &block).tap{ |f| @fields << f }
end