Sha256: 94a406aaf8a00bafe98421b2af1847b24bcc299c56aa432087290e88e889b08d

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

module ActiveESP
  class List
    # Returns or sets the list's identifier
    #
    # @return [String]
    attr_accessor :id

    # Returns or sets the list's name
    #
    # @return [String]
    attr_accessor :name

    # Initialize object with an optional attributes hash
    #
    # @param [Hash] attributes An optional hash of attributes to assign to the new instance
    def initialize(attributes = nil)
      if attributes.is_a? Hash
        attributes.each do |key, value|
          self.send(key.to_s + "=", value)
        end
      end
    end

    # Accessing commonly used API calls

    # Add the given subscriber to this list.
    #
    # @see ActiveESP::Providers::Interface#subscribe
    def subscribe!(subscriber)
      raise ActiveESP::ProviderNotConfiguredException unless ActiveESP.provider
      ActiveESP.provider.subscribe(subscriber, self)
    end

    # Remove the given subscriber from this list.
    #
    # @see ActiveESP::Providers::Interface#unsubscribe
    def unsubscribe!(subscriber)
      raise ActiveESP::ProviderNotConfiguredException unless ActiveESP.provider
      ActiveESP.provider.unsubscribe(subscriber, self)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_esp-0.1.0.alpha4 lib/active_esp/list.rb
active_esp-0.1.0.alpha3 lib/active_esp/list.rb
active_esp-0.1.0.alpha2 lib/active_esp/list.rb
active_esp-0.1.0.alpha1 lib/active_esp/list.rb