Class: Smplkit::Management::Service
- Inherits:
-
Object
- Object
- Smplkit::Management::Service
- Defined in:
- lib/smplkit/management/models.rb
Overview
A service resource — a backend application or microservice in the customer’s stack that contexts can be evaluated against.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#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, created_at: nil, updated_at: nil) ⇒ Service
constructor
A new instance of Service.
- #save ⇒ Object (also: #save!)
Constructor Details
#initialize(client = nil, key:, id: nil, name: nil, created_at: nil, updated_at: nil) ⇒ Service
Returns a new instance of Service.
108 109 110 111 112 113 114 115 116 |
# File 'lib/smplkit/management/models.rb', line 108 def initialize(client = nil, key:, id: nil, name: nil, created_at: nil, updated_at: nil) @client = client @id = id @key = key @name = name @created_at = created_at @updated_at = updated_at end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
106 107 108 |
# File 'lib/smplkit/management/models.rb', line 106 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id.
106 107 108 |
# File 'lib/smplkit/management/models.rb', line 106 def id @id end |
#key ⇒ Object
Returns the value of attribute key.
106 107 108 |
# File 'lib/smplkit/management/models.rb', line 106 def key @key end |
#name ⇒ Object
Returns the value of attribute name.
106 107 108 |
# File 'lib/smplkit/management/models.rb', line 106 def name @name end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
106 107 108 |
# File 'lib/smplkit/management/models.rb', line 106 def updated_at @updated_at end |
Instance Method Details
#_apply(other) ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/smplkit/management/models.rb', line 139 def _apply(other) @id = other.id @key = other.key @name = other.name @created_at = other.created_at @updated_at = other.updated_at end |
#delete ⇒ Object Also known as: delete!
132 133 134 135 136 |
# File 'lib/smplkit/management/models.rb', line 132 def delete raise "Service was constructed without a client; cannot delete" if @client.nil? @client.delete(@key) end |
#save ⇒ Object Also known as: save!
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/smplkit/management/models.rb', line 118 def save raise "Service was constructed without a client; cannot save" if @client.nil? updated = if @created_at.nil? @client._create_service(self) else @client._update_service(self) end _apply(updated) self end |