Class: Fluent::Plugin::ElasticsearchStats::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/elasticsearch_stats/metadata.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata = {}, metadata_prefix: self.class.metadata_prefix) ⇒ Metadata

Returns a new instance of Metadata.



13
14
15
16
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 13

def initialize( = {}, metadata_prefix: self.class.)
  @metadata = {}.update()
  @metadata_prefix = 
end

Class Attribute Details

.metadata_prefixObject

Returns the value of attribute metadata_prefix.



8
9
10
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 8

def 
  @metadata_prefix
end

Instance Attribute Details

#metadataObject (readonly)

Returns the value of attribute metadata.



11
12
13
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 11

def 
  @metadata
end

#metadata_prefixObject (readonly)

Returns the value of attribute metadata_prefix.



11
12
13
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 11

def 
  @metadata_prefix
end

Instance Method Details

#dupObject



30
31
32
33
34
35
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 30

def dup
  self.class.new(
    .clone,
    metadata_prefix: .clone
  )
end

#get(label) ⇒ Object



26
27
28
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 26

def get(label)
  [label_for(label)]
end

#label_for(label) ⇒ Object



37
38
39
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 37

def label_for(label)
  "#{}#{label}"
end

#set(label:, value:) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 18

def set(label:, value:)
  return self if label.nil? || label.to_s.empty?

  @metadata[label_for(label)] = value

  self
end

#to_hObject



41
42
43
# File 'lib/fluent/plugin/elasticsearch_stats/metadata.rb', line 41

def to_h
  .clone
end