Module: ActsAsApprovable::Ownership
- Defined in:
- lib/acts_as_approvable/ownership.rb
Overview
This module provides the Approval class with the ability to assign records as an “owner” of the approval. This is especially useful for tracking purposes when you require it, and can be beneficial when you have an approval queue with a high rate of insertions.
By default the ownership functionality will reference a model named ‘User` and will allow any user to take ownership of an approval.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.configure(options = {}, &block) ⇒ Object
Configure approvals to allow ownership by a User model.
- .included(base) ⇒ Object
Class Method Details
.configure(options = {}, &block) ⇒ Object
Configure approvals to allow ownership by a User model.
If a block is given it will be applied to Approval at the class level, allowing you to override functionality on the fly.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/acts_as_approvable/ownership.rb', line 21 def self.configure( = {}, &block) approval = .delete(:model) { Approval } owner = .delete(:owner) { User } approval.send(:include, self) ActsAsApprovable.owner_class = owner ActsAsApprovable.owner_source = .delete(:source) approval.send(:belongs_to, :owner, :class_name => owner.to_s, :foreign_key => :owner_id) end |
.included(base) ⇒ Object
33 34 35 36 |
# File 'lib/acts_as_approvable/ownership.rb', line 33 def self.included(base) base.send(:include, InstanceMethods) base.extend(ClassMethods) end |