Class: Chewy::Index::Crutch::Crutches
- Inherits:
-
Object
- Object
- Chewy::Index::Crutch::Crutches
- Defined in:
- lib/chewy/index/crutch.rb
Instance Method Summary collapse
-
#initialize(index, collection) ⇒ Crutches
constructor
A new instance of Crutches.
Constructor Details
#initialize(index, collection) ⇒ Crutches
Returns a new instance of Crutches.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/chewy/index/crutch.rb', line 12 def initialize(index, collection) @index = index @collection = collection @index._crutches.each_key do |name| singleton_class.class_eval <<-METHOD, __FILE__, __LINE__ + 1 def #{name} @#{name} ||= @index._crutches[:#{name}].call @collection end METHOD end end |