Class: Actions::EntryAction
Class Method Summary
collapse
Instance Method Summary
collapse
#exclusive_lock!, #link!
#serialize_args
Class Method Details
.all_action_names ⇒ Object
55
56
57
|
# File 'app/lib/actions/entry_action.rb', line 55
def self.all_action_names
subclasses.map { |k| k.allocate.humanized_name }
end
|
.serializer_class ⇒ Object
Instance Method Details
#action_subject(resource, *additional_args) ⇒ Object
Performs all that's needed to connect the action to the resource.
It converts the resource (and it's relatives defined in related_resources
to serialized form (using to_action_input).
It also locks the resource on the actions defined in resource_locks method.
The additional args can include more resources and/or a hash
with more data describing the action that should appear in the
action's input.
TODO redo as a middleware
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/lib/actions/entry_action.rb', line 34
def action_subject(resource, *additional_args)
Type! resource, ForemanTasks::Concerns::ActionSubject
input.update serialize_args(resource, *resource.all_related_resources, *additional_args)
if resource.is_a? ActiveRecord::Base
if resource_locks == :link
link!(resource)
else
exclusive_lock!(resource)
end
end
end
|
#delay(_schedule_options, *args) ⇒ Object
59
60
61
|
# File 'app/lib/actions/entry_action.rb', line 59
def delay(_schedule_options, *args)
serializer_class.new args
end
|
#drop_all_locks!(_execution_plan) ⇒ Object
67
68
69
|
# File 'app/lib/actions/entry_action.rb', line 67
def drop_all_locks!(_execution_plan)
ForemanTasks::Lock.where(:task_id => task.id).destroy_all
end
|
#humanized_name ⇒ Object
51
52
53
|
# File 'app/lib/actions/entry_action.rb', line 51
def humanized_name
_(super)
end
|
#resource_locks ⇒ Object
what locks to use on the resource? All by default, can be overriden.
It might one or more locks available for the resource. This following
special values are supported as well:
:all: lock all possible operations (all locks defined in resource's
available_locks method. Only tasks that link to the resource are
allowed while running this task
:exclusive: same as :all + doesn't allow even linking to the resoruce.
typical example is deleting a container, preventing all actions
heppening on it's sub-resources (such a system).
:link: only link the task to the resource, not locking
anything except exclusive locks
20
21
22
|
# File 'app/lib/actions/entry_action.rb', line 20
def resource_locks
:all
end
|