Class: Courtier::Configuration::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/courtier/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ DSL

Returns a new instance of DSL.



280
281
282
283
# File 'lib/courtier/configuration.rb', line 280

def initialize(configuration)
  @configuration = configuration
  @_options = {}
end

Instance Method Details

#config(command, options = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


312
313
314
315
316
317
318
# File 'lib/courtier/configuration.rb', line 312

def config(command, options={}, &block)
  nested_keys = @_options.keys & options.keys.map{|k| k.to_sym}
  raise ArgumentError, "nested #{nested_keys.join(', ')}" unless nested_keys.empty?

  options = @_options.merge(options)
  @configuration.config(command, options, &block)
end

#onload(feature, options = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


322
323
324
325
326
327
328
329
# File 'lib/courtier/configuration.rb', line 322

def onload(feature, options={}, &block)
  nested_keys = @_options.keys & options.keys.map{|k| k.to_sym}
  raise ArgumentError, "nested #{nested_keys.join(', ')}" unless nested_keys.empty?

  options = @_options.merge(options)
  options[:onload] = true
  @configuration.config(feature, options, &block)
end

#profile(name, state = {}, &block) ⇒ Object

Profile block.

Parameters:

  • name (String, Symbol)

    A profile name.

Raises:

  • (SyntaxError)


288
289
290
291
292
293
# File 'lib/courtier/configuration.rb', line 288

def profile(name, &block)
  raise SyntaxError, "nested profile sections" if @_options[:profile]
  @_options[:profile] = name.to_s
  instance_eval(&block)
  @_options.delete(:profile)
end