Class: ActiveRecord::Associations::AssociationProxy
- Inherits:
-
Object
- Object
- ActiveRecord::Associations::AssociationProxy
- Defined in:
- lib/rails2_ruby2/active_record_associations.rb
Direct Known Subclasses
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
Forwards any missing method call to the target.
12 13 14 15 16 17 18 19 20 |
# File 'lib/rails2_ruby2/active_record_associations.rb', line 12 def method_missing(method, *args, &block) if load_target if @target.respond_to?(method) || @target.protected_methods.include?(method) @target.send(method, *args, &block) else super end end end |
Instance Method Details
#proxy_respond_to?(method, include_all = false) ⇒ Boolean
4 5 6 7 |
# File 'lib/rails2_ruby2/active_record_associations.rb', line 4 def proxy_respond_to?(method, include_all = false) Object.instance_method(:respond_to?).bind(self).call(method, include_all) || (!include_all && Object.instance_method(:protected_methods).bind(self).call.include?(method)) end |