Class: Smplkit::Management::ContextType
- Inherits:
-
Object
- Object
- Smplkit::Management::ContextType
- Defined in:
- lib/smplkit/management/models.rb
Overview
A context type resource (e.g. “user”, “account”).
Instance Attribute Summary collapse
-
#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, description: nil, created_at: nil, updated_at: nil) ⇒ ContextType
constructor
A new instance of ContextType.
- #save ⇒ Object (also: #save!)
Constructor Details
#initialize(client = nil, key:, id: nil, name: nil, description: nil, created_at: nil, updated_at: nil) ⇒ ContextType
Returns a new instance of ContextType.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/smplkit/management/models.rb', line 61 def initialize(client = nil, key:, id: nil, name: nil, description: nil, created_at: nil, updated_at: nil) @client = client @id = id @key = key @name = name @description = description @created_at = created_at @updated_at = updated_at end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
59 60 61 |
# File 'lib/smplkit/management/models.rb', line 59 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
59 60 61 |
# File 'lib/smplkit/management/models.rb', line 59 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
59 60 61 |
# File 'lib/smplkit/management/models.rb', line 59 def id @id end |
#key ⇒ Object
Returns the value of attribute key.
59 60 61 |
# File 'lib/smplkit/management/models.rb', line 59 def key @key end |
#name ⇒ Object
Returns the value of attribute name.
59 60 61 |
# File 'lib/smplkit/management/models.rb', line 59 def name @name end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
59 60 61 |
# File 'lib/smplkit/management/models.rb', line 59 def updated_at @updated_at end |
Instance Method Details
#_apply(other) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/smplkit/management/models.rb', line 93 def _apply(other) @id = other.id @key = other.key @name = other.name @description = other.description @created_at = other.created_at @updated_at = other.updated_at end |
#delete ⇒ Object Also known as: delete!
86 87 88 89 90 |
# File 'lib/smplkit/management/models.rb', line 86 def delete raise "ContextType was constructed without a client; cannot delete" if @client.nil? @client.delete(@key) end |
#save ⇒ Object Also known as: save!
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/smplkit/management/models.rb', line 72 def save raise "ContextType was constructed without a client; cannot save" if @client.nil? updated = if @created_at.nil? @client._create_context_type(self) else @client._update_context_type(self) end _apply(updated) self end |