Sha256: ccb2e3a4113a99f450f73884207552e842ef9bb6a68044f83cbbb6cd118a785e
Contents?: true
Size: 1003 Bytes
Versions: 1
Compression:
Stored size: 1003 Bytes
Contents
module Trumpet class Channel @@attributes = [ :name, :created_at, :updated_at ] attr_reader *@@attributes def self.create(options) Channel.new(Trumpet::Request.post('/channels', :parameters => options)) end def self.find(name) Channel.new(Trumpet::Request.get("/channels/#{name}")) end def self.all Trumpet::Request.get('/channels').map { |attributes| Channel.new(attributes) } end def broadcast(message) Message.new(Trumpet::Request.post("/channels/#{@name}/messages", :parameters => message.to_h)) end def messages messages = Trumpet::Request.get("/channels/#{@name}/messages") messages.map { |attributes| Message.new(attributes) } end protected def initialize(attributes) @@attributes.each do |attr| self.instance_variable_set(:"@#{attr.to_s}", attributes[attr.to_s]) if attributes[attr.to_s] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trumpet-trumpet-0.0.2 | lib/trumpet/channel.rb |