Class: XRay::SubMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/aws-xray-sdk/model/metadata.rb

Overview

The actual class that stores all data under a certain namespace.

Instance Method Summary collapse

Constructor Details

#initialize(entity) ⇒ SubMeta

Returns a new instance of SubMeta.



26
27
28
29
# File 'lib/aws-xray-sdk/model/metadata.rb', line 26

def initialize(entity)
  @data = {}
  @entity = entity
end

Instance Method Details

#[](key) ⇒ Object



31
32
33
# File 'lib/aws-xray-sdk/model/metadata.rb', line 31

def [](key)
  @data[key]
end

#[]=(k, v) ⇒ Object

Raises:



35
36
37
38
# File 'lib/aws-xray-sdk/model/metadata.rb', line 35

def []=(k, v)
  raise EntityClosedError if @entity.closed?
  @data[k] = v
end

#to_hObject



45
46
47
# File 'lib/aws-xray-sdk/model/metadata.rb', line 45

def to_h
  @data
end

#to_jsonObject



49
50
51
52
53
# File 'lib/aws-xray-sdk/model/metadata.rb', line 49

def to_json
  @to_json ||= begin
    Oj.dump to_h, mode: :compat, use_as_json: true
  end
end

#update(h) ⇒ Object

Raises:



40
41
42
43
# File 'lib/aws-xray-sdk/model/metadata.rb', line 40

def update(h)
  raise EntityClosedError if @entity.closed?
  @data.merge!(h)
end