Class: Urbit::Fact::GraphUpdateFact
Instance Attribute Summary
Attributes inherited from BaseFact
#ack, #channel, #data, #type
Instance Method Summary
collapse
Methods inherited from BaseFact
#add_ack, #contents, #create_parser, #for_this_ship?, #is_acknowledged?, #raw_json, #ship, #to_s
Constructor Details
#initialize(channel:, event:) ⇒ GraphUpdateFact
Returns a new instance of GraphUpdateFact.
6
7
8
|
# File 'lib/urbit/fact/graph_fact.rb', line 6
def initialize(channel:, event:)
super channel: channel, event: event
end
|
Instance Method Details
#attach_parser ⇒ Object
Attach this new fact as a node to its Graph.
13
14
15
16
17
18
19
|
# File 'lib/urbit/fact/graph_fact.rb', line 13
def attach_parser
if self.incoming_graph
self.create_parser
end
end
|
#graph_update? ⇒ Boolean
21
22
23
|
# File 'lib/urbit/fact/graph_fact.rb', line 21
def graph_update?
true
end
|
#incoming_graph ⇒ Object
25
26
27
|
# File 'lib/urbit/fact/graph_fact.rb', line 25
def incoming_graph
self.ship.graph(resource: self.resource)
end
|
#resource ⇒ Object
29
30
31
|
# File 'lib/urbit/fact/graph_fact.rb', line 29
def resource
return "~#{self.resource_h["ship"]}/#{self.resource_h["name"]}" unless self.resource_h.nil?
end
|
#resource_h ⇒ Object
33
34
35
|
# File 'lib/urbit/fact/graph_fact.rb', line 33
def resource_h
self.raw_json["resource"]
end
|
#root_h ⇒ Object
37
38
39
|
# File 'lib/urbit/fact/graph_fact.rb', line 37
def root_h
self.contents["json"]["graph-update"]
end
|
#to_h ⇒ Object
41
42
43
|
# File 'lib/urbit/fact/graph_fact.rb', line 41
def to_h
super.merge!(resource: self.resource)
end
|