Class: Prefab::Context::NamedContext
- Inherits:
-
Object
- Object
- Prefab::Context::NamedContext
- Defined in:
- lib/prefab/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
- #to_h ⇒ Object
- #to_proto ⇒ Object
Constructor Details
#initialize(name, hash) ⇒ NamedContext
Returns a new instance of NamedContext.
10 11 12 13 |
# File 'lib/prefab/context.rb', line 10 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.
8 9 10 |
# File 'lib/prefab/context.rb', line 8 def name @name end |
Instance Method Details
#key ⇒ Object
19 20 21 |
# File 'lib/prefab/context.rb', line 19 def key "#{@name}:#{@hash['key']}" end |
#to_h ⇒ Object
15 16 17 |
# File 'lib/prefab/context.rb', line 15 def to_h @hash end |
#to_proto ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/prefab/context.rb', line 23 def to_proto PrefabProto::Context.new( type: name, values: @hash.transform_values do |value| ConfigValueWrapper.wrap(value) end ) end |