Module: Findable::Schema::ClassMethods

Defined in:
lib/findable/schema.rb

Instance Method Summary collapse

Instance Method Details

#column_namesObject



13
14
15
# File 'lib/findable/schema.rb', line 13

def column_names
  @_column_names ||= [:id]
end

#define_field(*args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/findable/schema.rb', line 17

def define_field(*args)
  options = args.extract_options!
  name = args.first
  if !public_method_defined?(name) || options.present?
    define_attribute_methods name
    conversion = Conversion.for(options[:type])
    define_method(name) { conversion.call(attributes[name.to_sym]) }
    column_names << name.to_sym
  end
end