Class: Opium::Push

Inherits:
Object show all
Includes:
Model::Connectable
Defined in:
lib/opium/push.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Push

Returns a new instance of Push.



7
8
9
10
# File 'lib/opium/push.rb', line 7

def initialize( attributes = {} )
  self.channels = []
  self.data = {}.with_indifferent_access
end

Instance Attribute Details

#channelsObject

Returns the value of attribute channels.



12
13
14
# File 'lib/opium/push.rb', line 12

def channels
  @channels
end

#dataObject

Returns the value of attribute data.



12
13
14
# File 'lib/opium/push.rb', line 12

def data
  @data
end

Instance Method Details

#alertObject



14
15
16
# File 'lib/opium/push.rb', line 14

def alert
  data[:alert]
end

#alert=(value) ⇒ Object



18
19
20
# File 'lib/opium/push.rb', line 18

def alert=( value )
  self.data[:alert] = value
end

#createObject



22
23
24
25
26
27
28
# File 'lib/opium/push.rb', line 22

def create
  fail ArgumentError, 'No channels were specified!' if channels.empty?
  self.class.as_resource(:push) do
    result = self.class.http_post post_data
    result[:result]
  end
end