Class: Urbit::Fact::MetadataUpdateFact
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?, #graph_update?, #is_acknowledged?, #raw_json, #ship, #to_s
Constructor Details
Returns a new instance of MetadataUpdateFact.
8
9
10
11
12
13
14
15
|
# File 'lib/urbit/fact/metadata_fact.rb', line 8
def initialize(channel:, event:)
super channel: channel, event: event
unless self.is_remove
self.accept if self.for_this_ship?
end
end
|
Instance Method Details
#accept ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/urbit/fact/metadata_fact.rb', line 17
def accept
links = self.channel.ship.links
if self.add_root.nil?
self.associations.each do |k, v|
links << Link.new(chain: links, path: k, data: v)
end
else
g = self.add_root["group"]
links << Link.new(chain: links, path: "#{g}/groups#{g}", data: self.add_root)
end
nil
end
|
#add_root ⇒ Object
31
32
33
|
# File 'lib/urbit/fact/metadata_fact.rb', line 31
def add_root
self.root_h["add"]
end
|
#associations ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/urbit/fact/metadata_fact.rb', line 35
def associations
unless (a = self.root_h["associations"])
return self.root_h["initial-group"]["associations"]
end
a
end
|
#is_remove ⇒ Object
44
45
46
|
# File 'lib/urbit/fact/metadata_fact.rb', line 44
def is_remove
self.root_h["remove"]
end
|
#root_h ⇒ Object
48
49
50
|
# File 'lib/urbit/fact/metadata_fact.rb', line 48
def root_h
self.contents["json"]["metadata-update"]
end
|
#to_h ⇒ Object
52
53
54
|
# File 'lib/urbit/fact/metadata_fact.rb', line 52
def to_h
super.merge!(resource: self.resource)
end
|