Class: RC::DSL
- Inherits:
-
Module
- Object
- Module
- RC::DSL
- Defined in:
- lib/rc/dsl.rb
Overview
Configuration’s DSL
Instance Method Summary collapse
- #config(command = nil, options = {}, &block) ⇒ Object
- #import(glob, opts = {}) ⇒ Object
-
#initialize(configuration) ⇒ DSL
constructor
A new instance of DSL.
- #onload(feature, options = {}, &block) ⇒ Object
-
#profile(name, state = {}, &block) ⇒ Object
Profile block.
Constructor Details
#initialize(configuration) ⇒ DSL
Returns a new instance of DSL.
10 11 12 13 |
# File 'lib/rc/dsl.rb', line 10 def initialize(configuration) @configuration = configuration @_options = {} end |
Instance Method Details
#config(command = nil, options = {}, &block) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/rc/dsl.rb', line 49 def config(command=nil, ={}, &block) nested_keys = @_options.keys & .keys.map{|k| k.to_sym} raise ArgumentError, "nested #{nested_keys.join(', ')}" unless nested_keys.empty? = @_options.merge() @configuration.config(command, , &block) end |
#import(glob, opts = {}) ⇒ Object
16 17 18 |
# File 'lib/rc/dsl.rb', line 16 def import(glob, opts={}) @configuration.import(glob, *opts) end |
#onload(feature, options = {}, &block) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/rc/dsl.rb', line 60 def onload(feature, ={}, &block) nested_keys = @_options.keys & .keys.map{|k| k.to_sym} raise ArgumentError, "nested #{nested_keys.join(', ')}" unless nested_keys.empty? = @_options.merge() [:onload] = true @configuration.config(feature, , &block) end |
#profile(name, state = {}, &block) ⇒ Object
Profile block.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rc/dsl.rb', line 36 def profile(name, state={}, &block) raise SyntaxError, "nested profile sections" if @_options[:profile] original_state = @_options.dup @_options.update(state) @_options[:profile] = name.to_s instance_eval(&block) @_options = original_state end |