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