Module: Ricordami::HasIndices::ClassMethods

Defined in:
lib/ricordami/has_indices.rb

Instance Method Summary collapse

Instance Method Details

#define_singleton_method(*args, &block) ⇒ Object



97
98
99
100
101
# File 'lib/ricordami/has_indices.rb', line 97

def define_singleton_method(*args, &block)
  class << self
    self
  end.send(:define_method, *args, &block)
end

#index(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ricordami/has_indices.rb', line 14

def index(options = {})
  options.assert_valid_keys(:unique, :get_by, :value, :scope)
  fields = options.delete(:unique)
  return unique_index(fields, options) if fields.present?
  field = options.delete(:value)
  return value_index(field) if field.present?
  raise InvalidIndexDefinition.new(self.class)
end

#indicesObject



10
11
12
# File 'lib/ricordami/has_indices.rb', line 10

def indices
  @indices ||= {}
end