Class: Chewy::Type::Crutch::Crutches

Inherits:
Object
  • Object
show all
Defined in:
lib/chewy/type/crutch.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, collection) ⇒ Crutches

Returns a new instance of Crutches.



12
13
14
15
16
17
18
19
20
21
# File 'lib/chewy/type/crutch.rb', line 12

def initialize type, collection
  @type, @collection = type, collection
  @type._crutches.keys.each do |name|
    singleton_class.class_eval "      def \#{name}\n        @\#{name} ||= @type._crutches[:\#{name}].call @collection\n      end\n    METHOD\n  end\nend\n", __FILE__, __LINE__ + 1