Class: Quonfig::Context::NamedContext

Inherits:
Object
  • Object
show all
Defined in:
lib/quonfig/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/quonfig/context.rb', line 12

def name
  @name
end

Instance Method Details

#keyObject



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_hObject



19
20
21
# File 'lib/quonfig/context.rb', line 19

def to_h
  @hash
end