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.
11 12 13 |
# File 'lib/mongoid_ability/find_lock.rb', line 11 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
6 7 8 |
# File 'lib/mongoid_ability/find_lock.rb', line 6 def action @action end |
#options ⇒ Object
Returns the value of attribute options
6 7 8 |
# File 'lib/mongoid_ability/find_lock.rb', line 6 def @options end |
#owner ⇒ Object
Returns the value of attribute owner
6 7 8 |
# File 'lib/mongoid_ability/find_lock.rb', line 6 def owner @owner end |
#subject_id ⇒ Object
Returns the value of attribute subject_id
6 7 8 |
# File 'lib/mongoid_ability/find_lock.rb', line 6 def subject_id @subject_id end |
#subject_type ⇒ Object
Returns the value of attribute subject_type
6 7 8 |
# File 'lib/mongoid_ability/find_lock.rb', line 6 def subject_type @subject_type end |
Class Method Details
.call(*args) ⇒ Object
7 8 9 |
# File 'lib/mongoid_ability/find_lock.rb', line 7 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/mongoid_ability/find_lock.rb', line 15 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 |