Class: Tasking::Options

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Options

Returns a new instance of Options.



11
12
13
# File 'lib/tasking/options.rb', line 11

def initialize(hash)
  @options_hash = hash
end

Instance Attribute Details

#options_hashObject (readonly)

Returns the value of attribute options_hash.



3
4
5
# File 'lib/tasking/options.rb', line 3

def options_hash
  @options_hash
end

Class Method Details

.build(options) ⇒ Object



5
6
7
8
9
# File 'lib/tasking/options.rb', line 5

def self.build( options )
  return options if options.is_a?( self )

  new( options )
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
# File 'lib/tasking/options.rb', line 28

def ==(other)
  options_hash == extract_options_hash( other )
end

#[](key) ⇒ Object



15
16
17
# File 'lib/tasking/options.rb', line 15

def [](key)
  resolve_value( options_hash[key] )
end

#materialized_hashObject



32
33
34
35
36
# File 'lib/tasking/options.rb', line 32

def materialized_hash
  options_hash.map do |key, value|
    [ key, resolve_value( value ) ]
  end.to_h
end

#merge(other) ⇒ Object



19
20
21
# File 'lib/tasking/options.rb', line 19

def merge(other)
  self.class.new( options_hash.merge( extract_options_hash( other ) ) )
end

#merge!(other) ⇒ Object



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

def merge!(other)
  options_hash.merge!( extract_options_hash( other ) )
  self
end