Class: Quonfig::Context::NamedContext
- Inherits:
-
Object
- Object
- Quonfig::Context::NamedContext
- Defined in:
- lib/quonfig/context.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, hash) ⇒ NamedContext
constructor
A new instance of NamedContext.
- #key ⇒ Object
- #merge!(other) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name, hash) ⇒ NamedContext
Returns a new instance of NamedContext.
14 15 16 17 |
# File 'lib/quonfig/context.rb', line 14 def initialize(name, hash) @name = name.to_s @hash = hash.transform_keys(&:to_s) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/quonfig/context.rb', line 12 def name @name end |
Instance Method Details
#key ⇒ Object
23 24 25 |
# File 'lib/quonfig/context.rb', line 23 def key "#{@name}:#{@hash['key']}" end |
#merge!(other) ⇒ Object
27 28 29 30 |
# File 'lib/quonfig/context.rb', line 27 def merge!(other) other.each { |k, v| @hash[k.to_s] = v } self end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/quonfig/context.rb', line 19 def to_h @hash end |