Class: Smplkit::Management::ContextType

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/management/models.rb

Overview

A context type resource (e.g. “user”, “account”).

Instance Attribute Summary collapse

Instance Method Summary collapse

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_atObject

Returns the value of attribute created_at.



59
60
61
# File 'lib/smplkit/management/models.rb', line 59

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



59
60
61
# File 'lib/smplkit/management/models.rb', line 59

def description
  @description
end

#idObject

Returns the value of attribute id.



59
60
61
# File 'lib/smplkit/management/models.rb', line 59

def id
  @id
end

#keyObject

Returns the value of attribute key.



59
60
61
# File 'lib/smplkit/management/models.rb', line 59

def key
  @key
end

#nameObject

Returns the value of attribute name.



59
60
61
# File 'lib/smplkit/management/models.rb', line 59

def name
  @name
end

#updated_atObject

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

#deleteObject 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

#saveObject 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