Module: Bagman::Extension::ClassMethods

Defined in:
lib/bagman/extension.rb

Instance Method Summary collapse

Instance Method Details

#field(name, *args, &blk) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bagman/extension.rb', line 13

def field(name,*args,&blk)
  options = args.extract_options!
  type    = args.shift || :string

  column = SimpleColumn.new(name, :extended, type)

  define_method name do
    column.type_cast( self[name] )
    # TODO typecasting, racial profiling
  end

  define_method "#{name}=" do |value|
    self[name] = value.to_s
  end
end