Class: Urbit::Fact::SettingsEventFact

Inherits:
BaseFact
  • Object
show all
Defined in:
lib/urbit/fact/settings_fact.rb

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

#initialize(channel:, event:) ⇒ SettingsEventFact

Returns a new instance of SettingsEventFact.



7
8
9
10
# File 'lib/urbit/fact/settings_fact.rb', line 7

def initialize(channel:, event:)
  super channel: channel, event: event
  self.accept if self.for_this_ship?
end

Instance Method Details

#acceptObject



12
13
14
# File 'lib/urbit/fact/settings_fact.rb', line 12

def accept
  nil
end

#base_contentsObject



16
17
18
# File 'lib/urbit/fact/settings_fact.rb', line 16

def base_contents
  JSON.parse(@data)["json"]["settings-event"]
end

#bucketObject



20
21
22
# File 'lib/urbit/fact/settings_fact.rb', line 20

def bucket
  self.desk[bucket: self.bucket_key]
end

#bucket_keyObject



24
25
26
# File 'lib/urbit/fact/settings_fact.rb', line 24

def bucket_key
  self.contents["bucket-key"]
end

#deskObject



28
29
30
# File 'lib/urbit/fact/settings_fact.rb', line 28

def desk
  self.ship.settings[desk: self.desk_name]
end

#desk_nameObject



32
33
34
# File 'lib/urbit/fact/settings_fact.rb', line 32

def desk_name
  self.contents["desk"]
end

#to_hObject



36
37
38
39
40
41
# File 'lib/urbit/fact/settings_fact.rb', line 36

def to_h
  super.merge!({
    bucket: self.bucket_key,
    desk:   self.desk_name,
  })
end