Sha256: 475fc1ca88cfc871a16ca9bd4451bc4a3bd9f67f63ff88ead464a0f7bfe305a5
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module Trumpet class Listener @@attributes = [ :receiver_id, :owner_id, :uri, :schedule, :created_at, :updated_at, ] attr_reader *@@attributes def self.create(options) if options[:receiver_id] Listener.new(Trumpet::Request.post("/receivers/#{options[:receiver_id]}/listeners", :parameters => options)) else raise Trumpet::BadRequest, "Must specify a receiver id when creating a listener" end end def self.find(id) Listener.new(Trumpet::Request.get("/listeners/#{id}")) end def self.all_by_user(name) listeners = Trumpet::Request.get("/users/#{name}/listeners") listeners.map { |attributes| Listener.new(attributes) } end def self.delete !!Trumpet::Request.delete("/listeners/#{@id}") 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trumpet-trumpet-0.0.7 | lib/trumpet/listener.rb |
trumpet-trumpet-0.0.8 | lib/trumpet/listener.rb |
trumpet-trumpet-0.0.9 | lib/trumpet/listener.rb |