Class: Smplkit::Platform::Environment
- Inherits:
-
Object
- Object
- Smplkit::Platform::Environment
- Defined in:
- lib/smplkit/platform/models.rb
Overview
Environment resource (sync). Mutate fields, then call save.
Instance Attribute Summary collapse
-
#classification ⇒ Object
Returns the value of attribute classification.
-
#color ⇒ Object
Returns the value of attribute color.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #_apply(other) ⇒ Object
-
#delete ⇒ Object
(also: #delete!)
Delete this environment from the server.
-
#initialize(client = nil, name:, id: nil, color: nil, classification: EnvironmentClassification::STANDARD, created_at: nil, updated_at: nil) ⇒ Environment
constructor
A new instance of Environment.
-
#save ⇒ Object
(also: #save!)
Create or update this environment on the server.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(client = nil, name:, id: nil, color: nil, classification: EnvironmentClassification::STANDARD, created_at: nil, updated_at: nil) ⇒ Environment
Returns a new instance of Environment.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/smplkit/platform/models.rb', line 18 def initialize(client = nil, name:, id: nil, color: nil, classification: EnvironmentClassification::STANDARD, created_at: nil, updated_at: nil) @client = client @id = id @name = name @color = Platform.coerce_color(color) @classification = classification @created_at = created_at @updated_at = updated_at end |
Instance Attribute Details
#classification ⇒ Object
Returns the value of attribute classification.
15 16 17 |
# File 'lib/smplkit/platform/models.rb', line 15 def classification @classification end |
#color ⇒ Object
Returns the value of attribute color.
16 17 18 |
# File 'lib/smplkit/platform/models.rb', line 16 def color @color end |
#created_at ⇒ Object
Returns the value of attribute created_at.
15 16 17 |
# File 'lib/smplkit/platform/models.rb', line 15 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
15 16 17 |
# File 'lib/smplkit/platform/models.rb', line 15 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/smplkit/platform/models.rb', line 15 def name @name end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
15 16 17 |
# File 'lib/smplkit/platform/models.rb', line 15 def updated_at @updated_at end |
Instance Method Details
#_apply(other) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/smplkit/platform/models.rb', line 57 def _apply(other) @id = other.id @name = other.name @color = other.color @classification = other.classification @created_at = other.created_at @updated_at = other.updated_at end |
#delete ⇒ Object Also known as: delete!
Delete this environment from the server.
45 46 47 48 49 |
# File 'lib/smplkit/platform/models.rb', line 45 def delete raise "Environment was constructed without a client or id; cannot delete" if @client.nil? || @id.nil? @client.delete(@id) end |
#save ⇒ Object Also known as: save!
Create or update this environment on the server.
35 36 37 38 39 40 41 |
# File 'lib/smplkit/platform/models.rb', line 35 def save raise "Environment was constructed without a client; cannot save" if @client.nil? other = @created_at.nil? ? @client._create(self) : @client._update(self) _apply(other) self end |
#to_s ⇒ Object Also known as: inspect
52 53 54 |
# File 'lib/smplkit/platform/models.rb', line 52 def to_s "Environment(id=#{@id.inspect}, name=#{@name.inspect}, classification=#{@classification.inspect})" end |