Module: HasFinder::HasManyAssociation

Defined in:
lib/has_finder/has_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(ap) ⇒ Object



66
67
68
69
70
# File 'lib/has_finder/has_finder.rb', line 66

def self.included(ap)
  ap.class_eval do
    alias_method_chain :method_missing, :has_finder
  end
end

Instance Method Details

#method_missing_with_has_finder(method, *args, &block) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/has_finder/has_finder.rb', line 72

def method_missing_with_has_finder(method, *args, &block)
  if @reflection.klass.finders.include?(method)
    @reflection.klass.finders[method].call(self, *args)
  else
    method_missing_without_has_finder(method, *args, &block)
  end
end