Class: Subroutine::Factory::Config
- Inherits:
-
Object
- Object
- Subroutine::Factory::Config
- Defined in:
- lib/subroutine/factory/config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #after(&block) ⇒ Object
- #before(&block) ⇒ Object
- #extra(name, value = nil) ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #input(name, value) ⇒ Object
- #op(op_class) ⇒ Object
- #output(name) ⇒ Object
- #outputs(*names) ⇒ Object
- #parent(parent) ⇒ Object
- #setup(&block) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 |
# File 'lib/subroutine/factory/config.rb', line 12 def initialize() = || {} parent(.delete(:parent)) if [:parent] sanitize! end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/subroutine/factory/config.rb', line 10 def end |
Instance Method Details
#after(&block) ⇒ Object
47 48 49 |
# File 'lib/subroutine/factory/config.rb', line 47 def after(&block) [:afters].push(block) end |
#before(&block) ⇒ Object
43 44 45 |
# File 'lib/subroutine/factory/config.rb', line 43 def before(&block) [:befores].push(block) end |
#extra(name, value = nil) ⇒ Object
65 66 67 |
# File 'lib/subroutine/factory/config.rb', line 65 def extra(name, value = nil) [:extras][name.to_sym] = value end |
#input(name, value) ⇒ Object
51 52 53 |
# File 'lib/subroutine/factory/config.rb', line 51 def input(name, value) [:inputs][name.to_sym] = value end |
#op(op_class) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/subroutine/factory/config.rb', line 28 def op(op_class) [:op] = case op_class when String op_class when Class op_class.name else op_class.to_s end end |
#output(name) ⇒ Object
55 56 57 58 |
# File 'lib/subroutine/factory/config.rb', line 55 def output(name) .delete(:outputs) [:output] = name end |
#outputs(*names) ⇒ Object
60 61 62 63 |
# File 'lib/subroutine/factory/config.rb', line 60 def outputs(*names) .delete(:output) [:outputs] = names end |
#parent(parent) ⇒ Object
20 21 22 |
# File 'lib/subroutine/factory/config.rb', line 20 def parent(parent) inherit_from(parent) end |
#setup(&block) ⇒ Object
39 40 41 |
# File 'lib/subroutine/factory/config.rb', line 39 def setup(&block) [:setups].push(block) end |
#validate! ⇒ Object
24 25 26 |
# File 'lib/subroutine/factory/config.rb', line 24 def validate! raise "Missing op configuration" unless [:op] end |