class Urbit::Message
Attributes
app[R]
channel[R]
contents[R]
id[RW]
mark[R]
Public Class Methods
new(channel:, app: nil, mark: nil, contents: nil)
click to toggle source
# File lib/urbit/message.rb, line 8 def initialize(channel:, app: nil, mark: nil, contents: nil) @app = app @channel = channel @contents = contents @id = 0 @mark = mark end
Public Instance Methods
action()
click to toggle source
The value for “action” that the inbound API expects for this message type. defaults to “poke” for historical reasons, but each subclass should override appropriately.
# File lib/urbit/message.rb, line 20 def action "poke" end
channel_url()
click to toggle source
# File lib/urbit/message.rb, line 24 def channel_url "#{self.ship.config.api_base_url}/~/channel/#{self.channel.key}" end
request_body()
click to toggle source
# File lib/urbit/message.rb, line 28 def request_body self.to_a.to_json end
ship()
click to toggle source
# File lib/urbit/message.rb, line 32 def ship self.channel.ship end
to_a()
click to toggle source
# File lib/urbit/message.rb, line 36 def to_a [self.to_h] end
to_h()
click to toggle source
# File lib/urbit/message.rb, line 40 def to_h { action: self.action, app: app, id: id, json: contents, mark: mark, ship: ship.untilded_name } end
to_s()
click to toggle source
# File lib/urbit/message.rb, line 51 def to_s "a Message(#{self.to_h})" end
transmit()
click to toggle source
# File lib/urbit/message.rb, line 55 def transmit response = Faraday.put(channel_url) do |req| req.headers['Cookie'] = self.ship.cookie req.headers['Content-Type'] = 'application/json' req.body = request_body end # TODO: handle_error if response.status != 204 response end