Class: Smplkit::Logging::SmplLogGroup

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

Overview

A log group resource — a hierarchical bag of loggers with a shared configured level.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = nil, key:, id: nil, name: nil, level: nil, description: nil, parent_id: nil, environments: nil, created_at: nil, updated_at: nil) ⇒ SmplLogGroup

Returns a new instance of SmplLogGroup.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/smplkit/logging/models.rb', line 75

def initialize(client = nil, key:, id: nil, name: nil, level: nil,
               description: nil, parent_id: nil, environments: nil,
               created_at: nil, updated_at: nil)
  @client = client
  @id = id
  @key = key
  @name = name
  @level = level
  @description = description
  @parent_id = parent_id
  @environments = environments || {}
  @created_at = created_at
  @updated_at = updated_at
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def description
  @description
end

#environmentsObject

Returns the value of attribute environments.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def environments
  @environments
end

#idObject

Returns the value of attribute id.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def id
  @id
end

#keyObject

Returns the value of attribute key.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def key
  @key
end

#levelObject

Returns the value of attribute level.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def level
  @level
end

#nameObject

Returns the value of attribute name.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def parent_id
  @parent_id
end

#updated_atObject

Returns the value of attribute updated_at.



72
73
74
# File 'lib/smplkit/logging/models.rb', line 72

def updated_at
  @updated_at
end

Instance Method Details

#_apply(other) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/smplkit/logging/models.rb', line 111

def _apply(other)
  @id = other.id
  @key = other.key
  @name = other.name
  @level = other.level
  @description = other.description
  @parent_id = other.parent_id
  @environments = other.environments
  @created_at = other.created_at
  @updated_at = other.updated_at
end

#deleteObject Also known as: delete!



104
105
106
107
108
# File 'lib/smplkit/logging/models.rb', line 104

def delete
  raise "SmplLogGroup was constructed without a client; cannot delete" if @client.nil?

  @client.delete(@key)
end

#saveObject Also known as: save!



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/smplkit/logging/models.rb', line 90

def save
  raise "SmplLogGroup was constructed without a client; cannot save" if @client.nil?

  updated =
    if @created_at.nil?
      @client._create_log_group(self)
    else
      @client._update_log_group(self)
    end
  _apply(updated)
  self
end