Class: MongoidAbility::FindLock
- Inherits:
-
Struct
- Object
- Struct
- MongoidAbility::FindLock
- Defined in:
- lib/mongoid_ability/find_lock.rb
Overview
finds first lock that controls specified params
Direct Known Subclasses
Defined Under Namespace
Classes: FindDefaultLock, FindInheritedLock, FindOwnedLock
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#options ⇒ Object
Returns the value of attribute options.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#subject_id ⇒ Object
Returns the value of attribute subject_id.
-
#subject_type ⇒ Object
Returns the value of attribute subject_type.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(owner, action, subject_type, subject_id = nil, options = {}) ⇒ FindLock
constructor
A new instance of FindLock.
Constructor Details
#initialize(owner, action, subject_type, subject_id = nil, options = {}) ⇒ FindLock
Returns a new instance of FindLock.
9 10 11 |
# File 'lib/mongoid_ability/find_lock.rb', line 9 def initialize(owner, action, subject_type, subject_id = nil, = {}) super(owner, action, subject_type.to_s, subject_id, ) end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
4 5 6 |
# File 'lib/mongoid_ability/find_lock.rb', line 4 def action @action end |
#options ⇒ Object
Returns the value of attribute options
4 5 6 |
# File 'lib/mongoid_ability/find_lock.rb', line 4 def @options end |
#owner ⇒ Object
Returns the value of attribute owner
4 5 6 |
# File 'lib/mongoid_ability/find_lock.rb', line 4 def owner @owner end |
#subject_id ⇒ Object
Returns the value of attribute subject_id
4 5 6 |
# File 'lib/mongoid_ability/find_lock.rb', line 4 def subject_id @subject_id end |
#subject_type ⇒ Object
Returns the value of attribute subject_type
4 5 6 |
# File 'lib/mongoid_ability/find_lock.rb', line 4 def subject_type @subject_type end |
Class Method Details
.call(*args) ⇒ Object
5 6 7 |
# File 'lib/mongoid_ability/find_lock.rb', line 5 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/mongoid_ability/find_lock.rb', line 13 def call lock = nil subject_class.self_and_ancestors_with_default_locks.each do |cls| break if lock = FindOwnedLock.call(owner, action, cls, subject_id, ) break if lock = FindInheritedLock.call(owner, action, cls, subject_id, ) break if lock = FindDefaultLock.call(owner, action, cls, subject_id, ) end lock end |