Class: Marathon::Base
Overview
Base class for all the API specific classes.
Direct Known Subclasses
App, Constraint, Container, ContainerDocker, ContainerDockerPortMapping, ContainerVolume, Deployment, DeploymentAction, DeploymentInfo, DeploymentStep, Group, Groups, HealthCheck, Queue, Task
Instance Attribute Summary collapse
-
#info ⇒ Object
readonly
Returns the value of attribute info.
Instance Method Summary collapse
-
#initialize(hash, attr_accessors = []) ⇒ Base
constructor
Create the object
hash
: object returned from API. -
#to_json(opts = {}) ⇒ Object
Return application as JSON formatted string.
Methods included from Error
error_class, error_message, from_response
Constructor Details
#initialize(hash, attr_accessors = []) ⇒ Base
Create the object hash
: object returned from API. May be Hash or Array. attr_accessors
: List of attribute accessors.
11 12 13 14 15 16 17 |
# File 'lib/marathon/base.rb', line 11 def initialize(hash, attr_accessors = []) raise ArgumentError, 'hash must be a Hash' if attr_accessors and attr_accessors.size > 0 and not hash.is_a?(Hash) raise ArgumentError, 'hash must be Hash or Array' unless hash.is_a?(Hash) or hash.is_a?(Array) raise ArgumentError, 'attr_accessors must be an Array' unless attr_accessors.is_a?(Array) @info = Marathon::Util.keywordize_hash!(hash) attr_accessors.each { |e| add_attr_accessor(e) } end |
Instance Attribute Details
#info ⇒ Object (readonly)
Returns the value of attribute info.
6 7 8 |
# File 'lib/marathon/base.rb', line 6 def info @info end |
Instance Method Details
#to_json(opts = {}) ⇒ Object
Return application as JSON formatted string.
20 21 22 |
# File 'lib/marathon/base.rb', line 20 def to_json(opts = {}) info.to_json(opts) end |