Class: Parse::Push

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/push.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, channel = "") ⇒ Push

Returns a new instance of Push.



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

def initialize(data, channel = "")
  @data = data
  @channel = channel
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



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

def channel
  @channel
end

#channelsObject

Returns the value of attribute channels.



6
7
8
# File 'lib/parse/push.rb', line 6

def channels
  @channels
end

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/parse/push.rb', line 11

def data
  @data
end

#expiration_timeObject

Returns the value of attribute expiration_time.



10
11
12
# File 'lib/parse/push.rb', line 10

def expiration_time
  @expiration_time
end

#expiration_time_intervalObject

Returns the value of attribute expiration_time_interval.



9
10
11
# File 'lib/parse/push.rb', line 9

def expiration_time_interval
  @expiration_time_interval
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#saveObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/parse/push.rb', line 18

def save
  uri   = Protocol.push_uri
  
  body = { :data => @data, :channel => @channel }
  
  if @channels
    body.merge!({ :channels => @channels })
    body.delete :channel
  end
  
  body.merge!({ :expiration_time_interval => @expiration_time_interval }) if @expiration_time_interval
  body.merge!({ :expiration_time => @expiration_time }) if @expiration_time 
  body.merge!({ :type => @type }) if @type
  
  response = Parse.client.request uri, :post, body.to_json, nil
end