Module: Ampere::Keys

Defined in:
lib/ampere/keys.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

These methods get mixed in to class and instance



6
7
8
9
# File 'lib/ampere/keys.rb', line 6

def self.included(base)
  # base.extend(ClassMethods)
  base.extend(self)
end

Instance Method Details

#key_for_find(parent_model, id) ⇒ Object



11
12
13
14
15
16
# File 'lib/ampere/keys.rb', line 11

def key_for_find(parent_model, id)
  unless id =~ /\./
    id = "#{parent_model.to_s.downcase}.#{id}"
  end
  id
end

#key_for_has_many(parent_model, id, field) ⇒ Object



18
19
20
# File 'lib/ampere/keys.rb', line 18

def key_for_has_many(parent_model, id, field)
  [parent_model, id, 'has_many', field].flatten.join('.')
end

#key_for_index(field) ⇒ Object



22
23
24
# File 'lib/ampere/keys.rb', line 22

def key_for_index(field)
  ['ampere', 'index', model_name.downcase, field].flatten.join('.')
end