class Uber::Options

Public Class Methods

new(options) click to toggle source
# File lib/garcon/utility/uber/options.rb, line 5
def initialize(options)
  @static = options

  options.each do |k,v|
    self[k] = option = Value.new(v)
    @static = nil if option.dynamic?
  end
end

Public Instance Methods

eval(key, *args) click to toggle source

Evaluates a single value.

# File lib/garcon/utility/uber/options.rb, line 26
def eval(key, *args)
  self[key].evaluate(*args)
end
evaluate(context, *args) click to toggle source

Evaluates every element and returns a hash. Accepts context and arbitrary arguments.

# File lib/garcon/utility/uber/options.rb, line 19
def evaluate(context, *args)
  return @static unless dynamic?

  evaluate_for(context, *args)
end

Private Instance Methods

dynamic?() click to toggle source
# File lib/garcon/utility/uber/options.rb, line 39
def dynamic?
  not @static
end
evaluate_for(context, *args) click to toggle source
# File lib/garcon/utility/uber/options.rb, line 31
def evaluate_for(context, *args)
  {}.tap do |evaluated|
    each do |k,v|
      evaluated[k] = v.evaluate(context, *args)
    end
  end
end