Class: Uber::Options

Inherits:
Hash show all
Defined in:
lib/garcon/utility/uber/options.rb

Defined Under Namespace

Classes: Value

Instance Method Summary collapse

Methods inherited from Hash

#argumentize, #capitalize_keys, #compact, #except, #normalize_keys, #object_state, #only, #recursive_fetch, #recursive_merge, #recursively_capitalize_key, #recursively_normalize_keys, #recursively_stringify_key, #recursively_symbolize_keys, #recursively_transform_keys, #stringify_keys, #symbolize_keys, #to_struct, #transform_keys, #zip

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



5
6
7
8
9
10
11
12
# 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

Instance Method Details

#eval(key, *args) ⇒ Object

Evaluates a single value.



26
27
28
# File 'lib/garcon/utility/uber/options.rb', line 26

def eval(key, *args)
  self[key].evaluate(*args)
end

#evaluate(context, *args) ⇒ Object

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



19
20
21
22
23
# File 'lib/garcon/utility/uber/options.rb', line 19

def evaluate(context, *args)
  return @static unless dynamic?

  evaluate_for(context, *args)
end