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() @options = || {} parent(@options.delete(:parent)) if @options[: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 @options end |
Instance Method Details
#after(&block) ⇒ Object
47 48 49 |
# File 'lib/subroutine/factory/config.rb', line 47 def after(&block) @options[:afters].push(block) end |
#before(&block) ⇒ Object
43 44 45 |
# File 'lib/subroutine/factory/config.rb', line 43 def before(&block) @options[: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) @options[: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) @options[: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) @options[: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) @options.delete(:outputs) @options[:output] = name end |
#outputs(*names) ⇒ Object
60 61 62 63 |
# File 'lib/subroutine/factory/config.rb', line 60 def outputs(*names) @options.delete(:output) @options[: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) @options[:setups].push(block) end |
#validate! ⇒ Object
24 25 26 |
# File 'lib/subroutine/factory/config.rb', line 24 def validate! raise "Missing op configuration" unless @options[:op] end |