app/lib/actions/entry_action.rb in foreman-tasks-0.2.2 vs app/lib/actions/entry_action.rb in foreman-tasks-0.3.0
- old
+ new
@@ -16,26 +16,23 @@
# heppening on it's sub-resources (such a system).
def resource_locks
:all
end
- # Peforms all that's needed to connect the action to the resource.
+ # 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.
- def action_subject(resource, *additional_args)
- if resource.respond_to?(:related_resources_recursive)
- related_resources = resource.related_resources_recursive
- else
- related_resources = []
- end
- plan_self(serialize_args(resource, *related_resources, *additional_args))
+ def action_subject(resource, *additional_args) # TODO redo as a middleware
+ 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 == :exclusive
exclusive_lock!(resource)
else
lock!(resource, resource_locks)
@@ -43,9 +40,17 @@
end
end
def humanized_input
Helpers::Humanizer.new(self).input
+ end
+
+ def humanized_name
+ _(super)
+ end
+
+ def self.all_action_names
+ subclasses.map { |k| k.allocate.humanized_name }
end
end
end