Module: Actionizer

Defined in:
lib/actionizer.rb,
lib/actionizer/inputs.rb,
lib/actionizer/result.rb,
lib/actionizer/failure.rb,
lib/actionizer/version.rb

Defined Under Namespace

Modules: ClassMethods Classes: Failure, Inputs, Result

Constant Summary collapse

VERSION =
'0.15.1'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



8
9
10
# File 'lib/actionizer.rb', line 8

def input
  @input
end

#outputObject (readonly)

Returns the value of attribute output.



8
9
10
# File 'lib/actionizer.rb', line 8

def output
  @output
end

#raise_on_failureObject

Returns the value of attribute raise_on_failure.



9
10
11
# File 'lib/actionizer.rb', line 9

def raise_on_failure
  @raise_on_failure
end

Class Method Details

.included(base) ⇒ Object



11
12
13
# File 'lib/actionizer.rb', line 11

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#fail!(params = {}) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/actionizer.rb', line 89

def fail!(params = {})
  params.each_pair { |key, value| output[key] = value }

  output.fail

  raise Actionizer::Failure.new('Failed!', output)
end

#initialize(initial_input = {}) ⇒ Object



83
84
85
86
87
# File 'lib/actionizer.rb', line 83

def initialize(initial_input = {})
  @input = OpenStruct.new(initial_input)
  @output = Actionizer::Result.new
  @raise_on_failure = false
end