Class: MongoidAbility::ResolveLocks
- Inherits:
-
Struct
- Object
- Struct
- MongoidAbility::ResolveLocks
- Defined in:
- lib/mongoid_ability/resolve_locks.rb
Direct Known Subclasses
ResolveDefaultLocks, ResolveInheritedLocks, ResolveOwnerLocks
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 ⇒ Object
Returns the value of attribute subject.
-
#subject_class ⇒ Object
readonly
Returns the value of attribute subject_class.
-
#subject_id ⇒ Object
readonly
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(*args) ⇒ ResolveLocks
constructor
.
Constructor Details
#initialize(*args) ⇒ ResolveLocks
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 15 def initialize(*args) super(*args) @subject_class = subject_type.to_s.constantize @subject_id = subject.id if subject.present? raise StandardError, "#{subject_type} class does not have default locks" unless @subject_class.respond_to?(:default_locks) raise StandardError, "#{subject_type} class does not have default lock for :#{action} action" unless @subject_class.self_and_ancestors_with_default_locks.any? do |cls| cls.default_locks.any?{ |l| l.action == action } end end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
2 3 4 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 2 def action @action end |
#options ⇒ Object
Returns the value of attribute options
2 3 4 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 2 def @options end |
#owner ⇒ Object
Returns the value of attribute owner
2 3 4 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 2 def owner @owner end |
#subject ⇒ Object
Returns the value of attribute subject
2 3 4 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 2 def subject @subject end |
#subject_class ⇒ Object (readonly)
Returns the value of attribute subject_class.
4 5 6 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 4 def subject_class @subject_class end |
#subject_id ⇒ Object (readonly)
Returns the value of attribute subject_id.
4 5 6 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 4 def subject_id @subject_id end |
#subject_type ⇒ Object
Returns the value of attribute subject_type
2 3 4 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 2 def subject_type @subject_type end |
Class Method Details
.call(*args) ⇒ Object
9 10 11 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 9 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
29 30 31 |
# File 'lib/mongoid_ability/resolve_locks.rb', line 29 def call raise NotImplementedError end |