Class: Frigate::Operation::Action::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/frigate/operation/action/base.rb

Overview

This class is abstract.

Base class is an abstact class

Direct Known Subclasses

Create, Update

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, opts = {}) ⇒ Base

Returns a new instance of Base.

Parameters:



21
22
23
24
# File 'lib/frigate/operation/action/base.rb', line 21

def initialize(operation, opts={})
	@operation = operation
	@opts = opts
end

Instance Attribute Details

#action_resultObject (readonly)

Returns the value of attribute action_result.



17
18
19
# File 'lib/frigate/operation/action/base.rb', line 17

def action_result
  @action_result
end

#modelObject (readonly)

Returns the value of attribute model.



17
18
19
# File 'lib/frigate/operation/action/base.rb', line 17

def model
  @model
end

#model_formObject (readonly)

Returns the value of attribute model_form.



17
18
19
# File 'lib/frigate/operation/action/base.rb', line 17

def model_form
  @model_form
end

#operationObject (readonly)

Returns the value of attribute operation.



17
18
19
# File 'lib/frigate/operation/action/base.rb', line 17

def operation
  @operation
end

#optsObject (readonly)

Returns the value of attribute opts.



17
18
19
# File 'lib/frigate/operation/action/base.rb', line 17

def opts
  @opts
end

#paramsObject (readonly)

Returns the value of attribute params.



17
18
19
# File 'lib/frigate/operation/action/base.rb', line 17

def params
  @params
end

Class Method Details

.run(operation, params, opts = {}) ⇒ Object

Initializes action class and pass args to instance run method

Parameters:

  • operation (Frigate::Operation)

    receives an instace of subclass of Frigate::Operation

  • params (Hash)
  • opts (Hash) (defaults to: {})


12
13
14
# File 'lib/frigate/operation/action/base.rb', line 12

def run(operation, params, opts={})
	new(operation, opts).run(params)
end

Instance Method Details

#actionObject

You should define an action in here

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/frigate/operation/action/base.rb', line 32

def action
	raise NotImplementedError
end

#run(params) ⇒ Object

Runs action’s mechanism



27
28
29
# File 'lib/frigate/operation/action/base.rb', line 27

def run(params)
	(@params = params); action; model_form
end