Module: Mongoid::Associations::Decorator
- Included in:
- BelongsToAssociation, HasOneAssociation
- Defined in:
- lib/mongoid/associations/decorator.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mongoid/associations/decorator.rb', line 4 def self.included(base) base.class_eval do attr_reader :document # Grabs all the public methods on the document and adds them # to the association class. This is preferred over method_missing # since we can ask the class for its methods and get an # accurate list. def decorate! document.public_methods(false).each do |method| (class << self; self; end).class_eval do define_method method do |*args| document.send method, *args end end end end end end |