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.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/smplkit/logging/models.rb', line 166

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.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def description
  @description
end

#environmentsObject

Returns the value of attribute environments.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def environments
  @environments
end

#idObject

Returns the value of attribute id.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def id
  @id
end

#keyObject

Returns the value of attribute key.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def key
  @key
end

#levelObject

Returns the value of attribute level.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def level
  @level
end

#nameObject

Returns the value of attribute name.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def parent_id
  @parent_id
end

#updated_atObject

Returns the value of attribute updated_at.



163
164
165
# File 'lib/smplkit/logging/models.rb', line 163

def updated_at
  @updated_at
end

Instance Method Details

#_apply(other) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
# File 'lib/smplkit/logging/models.rb', line 202

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!



195
196
197
198
199
# File 'lib/smplkit/logging/models.rb', line 195

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

  @client.delete(@key)
end

#saveObject Also known as: save!



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/smplkit/logging/models.rb', line 181

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