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. -
#runner() ⇒ Class
readonly
protected
The Runner class.
Instance Method Summary collapse
-
#call(input = nil) ⇒ Object
Invoke the Operation.
- #clone ⇒ Object
- #dup ⇒ Object
-
#error(klass) ⇒ Class?
Set the class wrapping the error data structure.
-
#error_constructor(sym_or_proc) ⇒ #call
Define how to build the
error. -
#finalize! ⇒ self
Disallow any further changes to this Operation.
-
#input(klass) ⇒ Class
Set the class wrapping the input data structure.
-
#input_constructor(sym_or_proc) ⇒ #call
Define how to build the
input. - #none ⇒ None
-
#output(klass) ⇒ Class
Set the class wrapping the output data structure.
-
#output_constructor(sym_or_proc) ⇒ #call
Define how to build the
output. -
#runner(klass = nil) ⇒ Object
protected
Overwrite the default runner.
Instance Attribute Details
#error() ⇒ Class (readonly)
Get the configured class wrapping the error data structure.
|
|
# File 'lib/teckel/operation.rb', line 241
|
#error_constructor() ⇒ Class (readonly)
The callable constructor to build an instance of the error class.
|
|
# File 'lib/teckel/operation.rb', line 254
|
#input() ⇒ Class (readonly)
Get the configured class wrapping the input data structure.
|
|
# File 'lib/teckel/operation.rb', line 139
|
#input_constructor() ⇒ Class (readonly)
The callable constructor to build an instance of the input class.
|
|
# File 'lib/teckel/operation.rb', line 152
|
#output() ⇒ Class (readonly)
Get the configured class wrapping the output data structure.
|
|
# File 'lib/teckel/operation.rb', line 197
|
#output_constructor() ⇒ Class (readonly)
The callable constructor to build an instance of the output class.
|
|
# File 'lib/teckel/operation.rb', line 210
|
#runner() ⇒ Class (readonly, protected)
Returns The Runner class.
|
|
# File 'lib/teckel/operation.rb', line 315
|
Instance Method Details
#call(input = nil) ⇒ Object
Invoke the Operation
331 332 333 |
# File 'lib/teckel/operation.rb', line 331 def call(input = nil) runner.new(self).call(input) end |
#clone ⇒ Object
365 366 367 368 369 370 371 372 373 |
# File 'lib/teckel/operation.rb', line 365 def clone if frozen? super else super.tap do |copy| copy.instance_variable_set(:@config, @config.dup) end end end |
#dup ⇒ Object
358 359 360 361 362 |
# File 'lib/teckel/operation.rb', line 358 def dup super.tap do |copy| copy.instance_variable_set(:@config, @config.dup) end end |
#error(klass) ⇒ Class?
Set the class wrapping the error data structure.
249 250 251 252 |
# File 'lib/teckel/operation.rb', line 249 def error(klass = nil) @config.for(:error, klass) { self::Error if const_defined?(:Error) } || raise(Teckel::MissingConfigError, "Missing error config for #{self}") end |
#error_constructor(sym_or_proc) ⇒ #call
Define how to build the error.
280 281 282 283 |
# File 'lib/teckel/operation.rb', line 280 def error_constructor(sym_or_proc = Config.default_constructor) @config.for(:error_constructor) { build_counstructor(error, sym_or_proc) } || raise(MissingConfigError, "Missing error_constructor config for #{self}") end |
#finalize! ⇒ self
Disallow any further changes to this Operation. Make sure all configurations are set.
350 351 352 353 354 355 |
# File 'lib/teckel/operation.rb', line 350 def finalize! define! freeze @config.freeze self end |
#input(klass) ⇒ Class
Set the class wrapping the input data structure.
147 148 149 150 |
# File 'lib/teckel/operation.rb', line 147 def input(klass = nil) @config.for(:input, klass) { self::Input if const_defined?(:Input) } || raise(Teckel::MissingConfigError, "Missing input config for #{self}") end |
#input_constructor(sym_or_proc) ⇒ #call
Define how to build the input.
192 193 194 195 |
# File 'lib/teckel/operation.rb', line 192 def input_constructor(sym_or_proc = Config.default_constructor) @config.for(:input_constructor) { build_counstructor(input, sym_or_proc) } || raise(MissingConfigError, "Missing input_constructor config for #{self}") end |
#none ⇒ None
311 312 313 |
# File 'lib/teckel/operation.rb', line 311 def none None end |
#output(klass) ⇒ Class
Set the class wrapping the output data structure.
205 206 207 208 |
# File 'lib/teckel/operation.rb', line 205 def output(klass = nil) @config.for(:output, klass) { self::Output if const_defined?(:Output) } || raise(Teckel::MissingConfigError, "Missing output config for #{self}") end |
#output_constructor(sym_or_proc) ⇒ #call
Define how to build the output.
236 237 238 239 |
# File 'lib/teckel/operation.rb', line 236 def output_constructor(sym_or_proc = Config.default_constructor) @config.for(:output_constructor) { build_counstructor(output, sym_or_proc) } || raise(MissingConfigError, "Missing output_constructor config for #{self}") end |
#runner(klass = nil) ⇒ Object (protected)
Overwrite the default runner
322 323 324 |
# File 'lib/teckel/operation.rb', line 322 def runner(klass = nil) @config.for(:runner, klass) { Runner } end |