Class: ConfigOMat::LoadedFacterProfile

Inherits:
ConfigItem
  • Object
show all
Defined in:
lib/config_o_mat/shared/types.rb

Constant Summary collapse

CLEAR_FROM_FACTER =
[
  "memoryfree", "memoryfree_mb", "load_averages", "uptime", "system_uptime", "uptime_seconds", "uptime_hours", "uptime_days",
  {"ec2_metadata" => ["identity-credentials", "iam"]},
  {"memory" => [{"system" => ["capacity", "available_bytes", "used", "used_bytes", "available"] }] }
].freeze

Instance Attribute Summary collapse

Attributes inherited from ConfigItem

#errors

Instance Method Summary collapse

Methods inherited from ConfigItem

#==, #error, #errors?, #validate!

Constructor Details

#initialize(name) ⇒ LoadedFacterProfile

Returns a new instance of LoadedFacterProfile.



219
220
221
222
223
# File 'lib/config_o_mat/shared/types.rb', line 219

def initialize(name)
  @name = name
  load_from_facter
  @version = contents.hash
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



217
218
219
# File 'lib/config_o_mat/shared/types.rb', line 217

def contents
  @contents
end

#nameObject (readonly)

Returns the value of attribute name.



217
218
219
# File 'lib/config_o_mat/shared/types.rb', line 217

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



217
218
219
# File 'lib/config_o_mat/shared/types.rb', line 217

def version
  @version
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


243
244
245
246
247
# File 'lib/config_o_mat/shared/types.rb', line 243

def eql?(other)
  return false if !super(other)
  return false if other.version != version || other.name != name
  true
end

#fallback?Boolean

Returns:

  • (Boolean)


225
226
227
# File 'lib/config_o_mat/shared/types.rb', line 225

def fallback?
  false
end

#hashObject



235
236
237
# File 'lib/config_o_mat/shared/types.rb', line 235

def hash
  @name.hash ^ @version
end

#to_hObject



239
240
241
# File 'lib/config_o_mat/shared/types.rb', line 239

def to_h
  @contents
end

#validateObject



229
230
231
232
233
# File 'lib/config_o_mat/shared/types.rb', line 229

def validate
  error :name, PRESENCE_ERROR_MSG if @name.nil? || @name.empty?
  error :contents, PRESENCE_ERROR_MSG if @contents.nil? || @contents.empty?
  error :contents, 'must be a hash' if !@contents.kind_of?(Hash)
end