Class: Urbit::Fact::SettingsEventPutEntryFact

Inherits:
SettingsEventFact 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 SettingsEventFact

#base_contents, #bucket, #bucket_key, #desk, #desk_name, #initialize

Methods inherited from BaseFact

#add_ack, #create_parser, #for_this_ship?, #graph_update?, #initialize, #is_acknowledged?, #raw_json, #ship, #to_s

Constructor Details

This class inherits a constructor from Urbit::Fact::SettingsEventFact

Instance Method Details

#acceptObject



92
93
94
95
96
97
# File 'lib/urbit/fact/settings_fact.rb', line 92

def accept
  # See if we already have this setting, if no add it, if yes update it.
  if (entries = channel.ship.settings[desk: self.desk_name].entries(bucket: self.bucket_key))
    entries[self.entry] = self.value
  end
end

#contentsObject



99
100
101
# File 'lib/urbit/fact/settings_fact.rb', line 99

def contents
  self.base_contents["put-entry"]
end

#entryObject



103
104
105
# File 'lib/urbit/fact/settings_fact.rb', line 103

def entry
  self.contents["entry-key"]
end

#to_hObject



107
108
109
110
111
112
# File 'lib/urbit/fact/settings_fact.rb', line 107

def to_h
  super.merge!({
    entry:  self.entry,
    value:  self.value
  })
end

#valueObject



114
115
116
# File 'lib/urbit/fact/settings_fact.rb', line 114

def value
  self.contents["value"]
end