Class: MongoidAbility::ResolveLocks

Inherits:
Struct
  • Object
show all
Defined in:
lib/mongoid_ability/resolve_locks.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ResolveLocks

Raises:

  • (StandardError)


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

#actionObject

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



2
3
4
# File 'lib/mongoid_ability/resolve_locks.rb', line 2

def action
  @action
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



2
3
4
# File 'lib/mongoid_ability/resolve_locks.rb', line 2

def options
  @options
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



2
3
4
# File 'lib/mongoid_ability/resolve_locks.rb', line 2

def owner
  @owner
end

#subjectObject

Returns the value of attribute subject

Returns:

  • (Object)

    the current value of subject



2
3
4
# File 'lib/mongoid_ability/resolve_locks.rb', line 2

def subject
  @subject
end

#subject_classObject (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_idObject (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_typeObject

Returns the value of attribute subject_type

Returns:

  • (Object)

    the current value of 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

#callObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/mongoid_ability/resolve_locks.rb', line 29

def call
  raise NotImplementedError
end