class Frigate::Operation::Action::Base
Base
class is an abstact class @abstract
Attributes
action_result[R]
model[R]
model_form[R]
operation[R]
opts[R]
params[R]
Public Class Methods
new(operation, opts={})
click to toggle source
@param [Frigate::Operation] operation @param [Hash] opts
# File lib/frigate/operation/action/base.rb, line 21 def initialize(operation, opts={}) @operation = operation @opts = opts end
run(operation, params, opts={})
click to toggle source
Initializes action class and pass args to instance run method @param [Frigate::Operation] operation receives an instace of subclass of Frigate::Operation
@param [Hash] params @param [Hash] opts
# File lib/frigate/operation/action/base.rb, line 12 def run(operation, params, opts={}) new(operation, opts).run(params) end
Public Instance Methods
action()
click to toggle source
You should define an action in here
# File lib/frigate/operation/action/base.rb, line 32 def action raise NotImplementedError end
run(params)
click to toggle source
Runs action's mechanism
# File lib/frigate/operation/action/base.rb, line 27 def run(params) (@params = params); action; model_form end
Protected Instance Methods
create_form(model)
click to toggle source
Creates an instance of operation subclass of Frigate::Form
for given model
# File lib/frigate/operation/action/base.rb, line 44 def create_form(model) operation.class.form_class.new(model) end
model_klass()
click to toggle source
Gets a model class of defined model class for operation
# File lib/frigate/operation/action/base.rb, line 39 def model_klass operation.class.model_klass end
operation_block(*args)
click to toggle source
A getter/caller of operation_block
from an operation class variable operation_block @note if no args passed then return the value of class variable operation_block @note if args passed then class variable operation_block is going to be called with these args
# File lib/frigate/operation/action/base.rb, line 51 def operation_block(*args) if args.empty? operation.class.operation_block else if operation_block.nil? raise StandardError.new('operation_block is nil') else operation.class.operation_block.call(*args) end end end