Sha256: 9fbce422ef21e564ca86554d7177474af8a2a367eb5ea62fa52c4d62d896463f

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

module Trumpet
  class Listener
    @@attributes = [
      :receiver_id,
      :uri,
      :start,
      :end,
      :days,
      :created_at,
      :updated_at,
    ]
    
    attr_reader *@@attributes
    
    
    def self.create(options)
      Listener.new(HTTP.post('/listeners', :parameters => options))
    end
    
    def self.find(id)
      Listener.new(HTTP.get("/listeners/#{id}"))
    end
    
    def self.delete
      HTTP.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

1 entries across 1 versions & 1 rubygems

Version Path
trumpet-trumpet-0.0.1 lib/trumpet/listener.rb