class SelfSDK::Messages::Fact
Attributes
attestations[RW]
expected_value[RW]
name[RW]
operator[RW]
sources[RW]
Public Class Methods
new(messaging)
click to toggle source
# File lib/messages/fact.rb, line 12 def initialize(messaging) @messaging = messaging end
Public Instance Methods
parse(fact)
click to toggle source
# File lib/messages/fact.rb, line 16 def parse(fact) @name = SelfSDK::fact_name(fact[:fact]) @operator = "" @operator = SelfSDK::operator(fact[:operator]) if fact[:operator] @sources = [] fact[:sources]&.each do |s| @sources << SelfSDK::source(s) end @expected_value = fact[:expected_value] || "" @attestations = [] fact[:attestations]&.each do |a| attestation = SelfSDK::Messages::Attestation.new(@messaging) attestation.parse(fact[:fact].to_sym, a) @attestations.push(attestation) end end
to_hash()
click to toggle source
# File lib/messages/fact.rb, line 43 def to_hash h = { fact: @name } unless @sources.nil? h[:sources] = @sources if @sources.length > 0 end h[:operator] = @operator unless @operator.empty? unless @attestations.nil? h[:attestations] = @attestations if @attestations.length > 0 end h[:expected_value] = @expected_value unless @expected_value.empty? h end
validate!(original)
click to toggle source
# File lib/messages/fact.rb, line 37 def validate!(original) @attestations.each do |a| a.validate! original end end