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.



16
17
18
19
# File 'lib/parse/push.rb', line 16

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

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



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

def channel
  @channel
end

#channelsObject

Returns the value of attribute channels.



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

def channels
  @channels
end

#dataObject

Returns the value of attribute data.



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

def data
  @data
end

#expiration_timeObject

Returns the value of attribute expiration_time.



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

def expiration_time
  @expiration_time
end

#expiration_time_intervalObject

Returns the value of attribute expiration_time_interval.



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

def expiration_time_interval
  @expiration_time_interval
end

#push_timeObject

Returns the value of attribute push_time.



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

def push_time
  @push_time
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#whereObject

Returns the value of attribute where.



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

def where
  @where
end

Instance Method Details

#saveObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/parse/push.rb', line 21

def save
  uri   = Protocol.push_uri

  body = { :data => @data, :channel => @channel }

  if @channels
    body.merge!({ :channels => @channels })
    body.delete :channel
  end

  if @where
    body.merge!({ :where => @where })
    body.delete :channel
  end

  body.merge!({ :expiration_interval => @expiration_time_interval }) if @expiration_time_interval
  body.merge!({ :expiration_time => @expiration_time }) if @expiration_time
  body.merge!({ :push_time => @push_time }) if @push_time
  body.merge!({ :type => @type }) if @type

  response = Parse.client.request uri, :post, body.to_json, nil
end