Module: Teckel::Operation::ClassMethods
- Defined in:
- lib/teckel/operation.rb
Instance Attribute Summary collapse
-
#error() ⇒ Class
readonly
Get the configured class wrapping the error data structure.
-
#error_constructor() ⇒ Class
readonly
The callable constructor to build an instance of the
errorclass. -
#input() ⇒ Class
readonly
Get the configured class wrapping the input data structure.
-
#input_constructor() ⇒ Class
readonly
The callable constructor to build an instance of the
inputclass. -
#output() ⇒ Class
readonly
Get the configured class wrapping the output data structure.
-
#output_constructor() ⇒ Class
readonly
The callable constructor to build an instance of the
outputclass.
Instance Method Summary collapse
-
#call(input) ⇒ Object
Invoke the Operation.
-
#error(klass) ⇒ Class
Set the class wrapping the error data structure.
-
#error_constructor(sym_or_proc) ⇒ #call
Define how to build the
error. -
#input(klass) ⇒ Class
Set the class wrapping the input data structure.
-
#input_constructor(sym_or_proc) ⇒ #call
Define how to build the
input. -
#output(klass) ⇒ Class
Set the class wrapping the output data structure.
-
#output_constructor(sym_or_proc) ⇒ #call
Define how to build the
output.
Instance Attribute Details
#error() ⇒ Class (readonly)
Get the configured class wrapping the error data structure.
|
|
# File 'lib/teckel/operation.rb', line 212
|
#error_constructor() ⇒ Class (readonly)
The callable constructor to build an instance of the error class.
|
|
# File 'lib/teckel/operation.rb', line 228
|
#input() ⇒ Class (readonly)
Get the configured class wrapping the input data structure.
|
|
# File 'lib/teckel/operation.rb', line 90
|
#input_constructor() ⇒ Class (readonly)
The callable constructor to build an instance of the input class.
|
|
# File 'lib/teckel/operation.rb', line 106
|
#output() ⇒ Class (readonly)
Get the configured class wrapping the output data structure.
|
|
# File 'lib/teckel/operation.rb', line 158
|
#output_constructor() ⇒ Class (readonly)
The callable constructor to build an instance of the output class.
|
|
# File 'lib/teckel/operation.rb', line 174
|
Instance Method Details
#call(input) ⇒ Object
Invoke the Operation
270 271 272 |
# File 'lib/teckel/operation.rb', line 270 def call(input) new.call!(input) end |
#error(klass) ⇒ Class
Set the class wrapping the error data structure.
220 221 222 223 224 225 226 |
# File 'lib/teckel/operation.rb', line 220 def error(klass = nil) return @error_class if @error_class @error_class = @config.error(klass) @error_class ||= self::Error if const_defined?(:Error) @error_class end |
#error_constructor(sym_or_proc) ⇒ #call
Define how to build the error.
254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/teckel/operation.rb', line 254 def error_constructor(sym_or_proc = nil) return @error_constructor if @error_constructor constructor = @config.error_constructor(sym_or_proc) @error_constructor = if constructor.is_a?(Symbol) && error.respond_to?(constructor) error.public_method(constructor) elsif sym_or_proc.respond_to?(:call) sym_or_proc end end |
#input(klass) ⇒ Class
Set the class wrapping the input data structure.
98 99 100 101 102 103 104 |
# File 'lib/teckel/operation.rb', line 98 def input(klass = nil) return @input_class if @input_class @input_class = @config.input(klass) @input_class ||= self::Input if const_defined?(:Input) @input_class end |
#input_constructor(sym_or_proc) ⇒ #call
Define how to build the input.
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/teckel/operation.rb', line 146 def input_constructor(sym_or_proc = nil) return @input_constructor if @input_constructor constructor = @config.input_constructor(sym_or_proc) @input_constructor = if constructor.is_a?(Symbol) && input.respond_to?(constructor) input.public_method(constructor) elsif sym_or_proc.respond_to?(:call) sym_or_proc end end |
#output(klass) ⇒ Class
Set the class wrapping the output data structure.
166 167 168 169 170 171 172 |
# File 'lib/teckel/operation.rb', line 166 def output(klass = nil) return @output_class if @output_class @output_class = @config.output(klass) @output_class ||= self::Output if const_defined?(:Output) @output_class end |
#output_constructor(sym_or_proc) ⇒ #call
Define how to build the output.
200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/teckel/operation.rb', line 200 def output_constructor(sym_or_proc = nil) return @output_constructor if @output_constructor constructor = @config.output_constructor(sym_or_proc) @output_constructor = if constructor.is_a?(Symbol) && output.respond_to?(constructor) output.public_method(constructor) elsif sym_or_proc.respond_to?(:call) sym_or_proc end end |