Class: SelfSDK::Services::Facts::Fact

Inherits:
Object
  • Object
show all
Defined in:
lib/services/facts.rb

Overview

Facts to be issued

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, source, opts = {}) ⇒ Fact

Returns a new instance of Fact.



120
121
122
123
124
125
126
127
# File 'lib/services/facts.rb', line 120

def initialize(key, value, source, opts = {})
  @key = key
  @value = value
  @source = source
  @display_name = opts.fetch(:display_name, "")
  @group = opts.fetch(:group, nil)
  @type = opts.fetch(:type, nil)
end

Instance Attribute Details

#groupObject

Returns the value of attribute group.



117
118
119
# File 'lib/services/facts.rb', line 117

def group
  @group
end

#keyObject

Returns the value of attribute key.



117
118
119
# File 'lib/services/facts.rb', line 117

def key
  @key
end

#valueObject

Returns the value of attribute value.



117
118
119
# File 'lib/services/facts.rb', line 117

def value
  @value
end

Instance Method Details

#to_hashObject



129
130
131
132
133
134
# File 'lib/services/facts.rb', line 129

def to_hash
  b = { key: @key, value: @value, source: @source }
  b[:group] = @group.to_hash unless @group.nil?
  b[:type] = @type unless @type.nil?
  b
end