Module: DelegateBelongsTo
- Defined in:
- lib/spree_core/delegate_belongs_to.rb
Overview
Creates methods on object which delegate to an association proxy. see delegate_belongs_to for two uses
Todo - integrate with ActiveRecord::Dirty to make sure changes to delegate object are noticed Should do class User < ActiveRecord::Base; delegate_belongs_to :contact, :firstname; end class Contact < ActiveRecord::Base; end u = User.first u.changed? # => false u.firstname = ‘Bobby’ u.changed? # => true
Right now the second call to changed? would return false
Todo - add has_one support. fairly straightforward addition
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.included(receiver) ⇒ Object
88 89 90 91 |
# File 'lib/spree_core/delegate_belongs_to.rb', line 88 def self.included(receiver) receiver.extend ClassMethods receiver.send :include, InstanceMethods end |