Module: Findable::Schema::ClassMethods

Defined in:
lib/findable/schema.rb

Instance Method Summary collapse

Instance Method Details

#column_namesObject



16
17
18
# File 'lib/findable/schema.rb', line 16

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

#define_field(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/findable/schema.rb', line 28

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

#index_defined?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/findable/schema.rb', line 24

def index_defined?
  indexes.size > 1
end

#indexesObject



20
21
22
# File 'lib/findable/schema.rb', line 20

def indexes
  @_indexes ||= [:id]
end