Module: Hypostasis::Document::Indexes::ClassMethods

Defined in:
lib/hypostasis/document/indexes.rb

Instance Method Summary collapse

Instance Method Details

#index(field_name, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/hypostasis/document/indexes.rb', line 13

def index(field_name, options = {})
  self.class_eval do
    class_variable_set(:@@indexed_fields, []) unless class_variable_defined?(:@@indexed_fields)
    registered_indexed_fields = class_variable_get(:@@indexed_fields)
    registered_indexed_fields << field_name.to_sym
    class_variable_set(:@@indexed_fields, registered_indexed_fields)
  end
end

#indexed_fieldsObject



22
23
24
# File 'lib/hypostasis/document/indexes.rb', line 22

def indexed_fields
  self.class_eval { class_variable_get(:@@indexed_fields) }
end