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( = {}) .assert_valid_keys(:unique, :get_by, :value, :scope) fields = .delete(:unique) return unique_index(fields, ) if fields.present? field = .delete(:value) return value_index(field) if field.present? raise InvalidIndexDefinition.new(self.class) end |
#indices ⇒ Object
10 11 12 |
# File 'lib/ricordami/has_indices.rb', line 10 def indices @indices ||= {} end |