class Upmin::Action
Attributes
model[R]
name[R]
Public Class Methods
new(model, action_name, options = {})
click to toggle source
# File lib/upmin/action.rb, line 8 def initialize(model, action_name, options = {}) @model = model @name = action_name.to_sym end
Public Instance Methods
parameters()
click to toggle source
# File lib/upmin/action.rb, line 21 def parameters return @parameters if defined?(@parameters) @parameters = [] model.method(name).parameters.each do |param_type, param_name| @parameters << Upmin::Parameter.new(self, param_name, type: param_type) end return @parameters end
Also aliased as: arguments
path()
click to toggle source
# File lib/upmin/action.rb, line 17 def path return upmin_action_path(klass: model.model_class_name, id: model.id, method: name) end
perform(arguments)
click to toggle source
# File lib/upmin/action.rb, line 31 def perform(arguments) array = [] parameters.each do |parameter| if parameter.type == :req unless arguments[parameter.name] raise Upmin::MissingArgument.new(parameter.name) end array << arguments[parameter.name] elsif parameter.type == :opt array << arguments[parameter.name] if arguments[parameter.name] else # :block - skip it end end return model.send(name, *array) end
title()
click to toggle source
# File lib/upmin/action.rb, line 13 def title return name.to_s.humanize end