Module: Keymaker::Indexing::ClassMethods

Defined in:
lib/keymaker/indexing.rb

Instance Method Summary collapse

Instance Method Details

#index(index_name, options) ⇒ Object

index :threds, on: :name, with: :sanitized_name data structure: { threds: [{ :index_key => :name, :value => :sanitized_name }], users: [{ :index_key => :email, :value => :email }, { :index_key => :username, :value => :username }] }



18
19
20
# File 'lib/keymaker/indexing.rb', line 18

def index(index_name,options)
  index_row(index_name.to_s) << { :index_key => options[:on].to_s, :value => options.fetch(:with, options[:on]) }
end

#index_row(index_name) ⇒ Object



11
12
13
# File 'lib/keymaker/indexing.rb', line 11

def index_row(index_name)
  indices_traits[index_name] = indices_traits.fetch(index_name, [])
end