Method: SelfSDK::Messages::Fact#parse

Defined in:
lib/messages/fact.rb

#parse(fact) ⇒ Object

[View source]

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/messages/fact.rb', line 14

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