Class: Miasma::Types::Data

Inherits:
Object
  • Object
show all
Includes:
Utils::Lazy
Defined in:
lib/miasma/types/data.rb

Overview

Base data container

Direct Known Subclasses

Models::Compute::Server::Address, Models::LoadBalancer::Balancer::Address, Models::LoadBalancer::Balancer::HealthCheck, Models::LoadBalancer::Balancer::Listener, Models::Orchestration::Stack::Output, Model, ThinModel

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (self) initialize(args = {})

Build new data instance

Parameters:

  • args (Hash) (defaults to: {})

    attribute values



17
18
19
20
# File 'lib/miasma/types/data.rb', line 17

def initialize(args={})
  load_data(args)
  valid_state
end

Class Method Details

+ (Data) from_json(json)

Build new instance from JSON string

Parameters:

  • json (String)

Returns:



45
46
47
# File 'lib/miasma/types/data.rb', line 45

def from_json(json)
  self.new(MultiJson.load(json).to_smash)
end

Instance Method Details

- (self) from_json(json)

Load model using JSON string

Parameters:

  • json (String)

Returns:

  • (self)


33
34
35
36
37
# File 'lib/miasma/types/data.rb', line 33

def from_json(json)
  load_data(
    MultiJson.load(json).to_smash
  ).valid_state
end

- (String) to_json(*_)

Convert model to JSON string

Returns:

  • (String)


25
26
27
# File 'lib/miasma/types/data.rb', line 25

def to_json(*_)
  MultiJson.dump(attributes)
end