Class: Uber::Options

Inherits:
Hash
  • Object
show all
Defined in:
lib/uber/options.rb

Defined Under Namespace

Classes: Value

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Options

Returns a new instance of Options.



6
7
8
9
10
11
12
# File 'lib/uber/options.rb', line 6

def initialize(options)
  @static = options

  options.each do |k,v|
    self[k] = Option[v, instance_exec: true]
  end
end

Instance Method Details

#eval(key, *args) ⇒ Object

Evaluates a single value.



24
25
26
# File 'lib/uber/options.rb', line 24

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

#evaluate(context, *args) ⇒ Object

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



15
16
17
18
19
20
21
# File 'lib/uber/options.rb', line 15

def evaluate(context, *args)
  {}.tap do |evaluated|
    each do |k,v|
      evaluated[k] = v.(context, *args)
    end
  end
end