class Detroit::Toolchain::Script::BlockContext

Attributes

settings[R]

Public Class Methods

new(&b) click to toggle source
# File lib/detroit/toolchain/script.rb, line 162
def initialize(&b)
  @settings = {}
  b.arity == 1 ? b.call(self) : instance_eval(&b)
end

Public Instance Methods

method_missing(symbol, value=nil, *args) click to toggle source
Calls superclass method
# File lib/detroit/toolchain/script.rb, line 179
def method_missing(symbol, value=nil, *args)
  case name = symbol.to_s
  when /=$/
    @settings[name.chomp('=')] = value
  else
    return super(symbol, value, *args) unless args.empty?
    if value
      @settings[name.to_s] = value
    else
      @settings[name.to_s]
    end
  end
end
set(name, value=nil, &block) click to toggle source
# File lib/detroit/toolchain/script.rb, line 168
def set(name, value=nil, &block)
  if block
    block_context = BlockContext.new
    block.call(block_context)
    @settings[name.to_s] = block_context.settings
  else
    @settings[name.to_s] = value
  end
end