Skip to content

Commit

Permalink
Added handling for crutch dependencies (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-apollo authored Sep 10, 2024
1 parent 023147d commit 754c612
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/chewy/type/crutch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ def initialize(type, collection)
@type._crutches.each_key do |name|
singleton_class.class_eval <<-METHOD, __FILE__, __LINE__ + 1
def #{name}
@#{name} ||= @type._crutches[:#{name}].call @collection
execution_block = @type._crutches[:#{name}]
if execution_block.arity == 1
@#{name} ||= execution_block.call @collection
else
@#{name} ||= execution_block.call @collection, self
end
end
METHOD
end
Expand Down

0 comments on commit 754c612

Please sign in to comment.