Class: RightScale::MetadataFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/clouds/metadata_formatter.rb

Overview

Abstracts a formatter which maps one kind of metadata output to another.

Constant Summary collapse

RS_METADATA_PREFIX =

RS_ is reserved for use by RightScale and should be avoided by users passing non-RightScale metadata to instances.

'RS_'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MetadataFormatter

Initializer.

Parameters

options(String)

default prefix for formatted metadata keys

options(Proc(formatter, metadata)

format_metadata override or nil



39
40
41
42
43
44
45
# File 'lib/clouds/metadata_formatter.rb', line 39

def initialize(options = {})
  # options
  @formatted_path_prefix = options[:formatted_path_prefix] || 

  # overrides
   = options[:format_metadata_override]
end

Instance Attribute Details

#format_metadata_overrideObject

Returns the value of attribute format_metadata_override.



32
33
34
# File 'lib/clouds/metadata_formatter.rb', line 32

def 
  
end

#formatted_path_prefixObject

Returns the value of attribute formatted_path_prefix.



32
33
34
# File 'lib/clouds/metadata_formatter.rb', line 32

def formatted_path_prefix
  @formatted_path_prefix
end

Instance Method Details

#format_metadata(metadata) ⇒ Object

Formats metadata such that any hierarchical details flattened into simple key names.

Parameters

tree_metadata(Hash)

tree of raw metadata

Returns

flat_metadata(Hash)

flattened metadata



55
56
57
58
# File 'lib/clouds/metadata_formatter.rb', line 55

def ()
  return .call(self, ) if 
  return ()
end