Class: Smplkit::Management::Environment
- Inherits:
-
Object
- Object
- Smplkit::Management::Environment
- Defined in:
- lib/smplkit/management/models.rb
Overview
An environment resource — a customer-defined deploy target (production, staging, etc.) for which configs and flags can have overrides.
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.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#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!)
-
#initialize(client = nil, key:, id: nil, name: nil, color: nil, classification: EnvironmentClassification::STANDARD, description: nil, created_at: nil, updated_at: nil) ⇒ Environment
constructor
A new instance of Environment.
- #save ⇒ Object (also: #save!)
Constructor Details
#initialize(client = nil, key:, id: nil, name: nil, color: nil, classification: EnvironmentClassification::STANDARD, description: nil, created_at: nil, updated_at: nil) ⇒ Environment
Returns a new instance of Environment.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/smplkit/management/models.rb', line 10 def initialize(client = nil, key:, id: nil, name: nil, color: nil, classification: EnvironmentClassification::STANDARD, description: nil, created_at: nil, updated_at: nil) @client = client @id = id @key = key @name = name @color = color @classification = classification @description = description @created_at = created_at @updated_at = updated_at end |
Instance Attribute Details
#classification ⇒ Object
Returns the value of attribute classification.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def classification @classification end |
#color ⇒ Object
Returns the value of attribute color.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def color @color end |
#created_at ⇒ Object
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def id @id end |
#key ⇒ Object
Returns the value of attribute key.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def key @key end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def name @name end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
8 9 10 |
# File 'lib/smplkit/management/models.rb', line 8 def updated_at @updated_at end |
Instance Method Details
#_apply(other) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/smplkit/management/models.rb', line 45 def _apply(other) @id = other.id @key = other.key @name = other.name @color = other.color @classification = other.classification @description = other.description @created_at = other.created_at @updated_at = other.updated_at end |
#delete ⇒ Object Also known as: delete!
38 39 40 41 42 |
# File 'lib/smplkit/management/models.rb', line 38 def delete raise "Environment was constructed without a client; cannot delete" if @client.nil? @client.delete(@key) end |
#save ⇒ Object Also known as: save!
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/smplkit/management/models.rb', line 24 def save raise "Environment was constructed without a client; cannot save" if @client.nil? updated = if @created_at.nil? @client._create_environment(self) else @client._update_environment(self) end _apply(updated) self end |