class Ari::Resource
Public Class Methods
client(options = {})
click to toggle source
# File lib/ari/resource.rb, line 10 def self.client(options = {}) client = options.fetch(:client, nil) return client if client Ari.client end
Public Instance Methods
add_listener(type, params = {}, &block)
click to toggle source
# File lib/ari/resource.rb, line 16 def add_listener(type, params = {}, &block) client.class.instance_listeners[type.to_sym] ||= [] unless client.class.instance_listeners[type.to_sym].any? { |l| l.id == self.id } client.class.instance_listeners[type.to_sym] << self end client.add_listener "#{type}-#{self.id}", params, &block end
Also aliased as: on
client(options = {})
click to toggle source
# File lib/ari/resource.rb, line 5 def client(options = {}) return @client if @client self.class.client(options) end
remove_all_listeners!()
click to toggle source
# File lib/ari/resource.rb, line 32 def remove_all_listeners! client.class.instance_listeners.each do |type, _| remove_listener type end end
Also aliased as: off_all!
remove_listener(type)
click to toggle source
# File lib/ari/resource.rb, line 25 def remove_listener(type) client.class.instance_listeners[type.to_sym] ||= [] client.class.instance_listeners[type].delete_if { |i| i.id == self.id } client.remove_listener "#{type}-#{self.id}" end
Also aliased as: off