Class: DigitalOceanInventory::Serializer
- Inherits:
-
Object
- Object
- DigitalOceanInventory::Serializer
- Defined in:
- lib/digital_ocean_inventory/serializer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #call(inventory) ⇒ Object
-
#initialize(config) ⇒ Serializer
constructor
A new instance of Serializer.
Constructor Details
#initialize(config) ⇒ Serializer
Returns a new instance of Serializer.
11 12 13 |
# File 'lib/digital_ocean_inventory/serializer.rb', line 11 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/digital_ocean_inventory/serializer.rb', line 5 def config @config end |
Class Method Details
.build(config) ⇒ Object
7 8 9 |
# File 'lib/digital_ocean_inventory/serializer.rb', line 7 def self.build(config) new config end |
Instance Method Details
#call(inventory) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/digital_ocean_inventory/serializer.rb', line 15 def call(inventory) = { _meta: { hostvars: hostvars(inventory) } } data = groups(inventory).merge JSON.dump data end |