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.



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

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.



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

def data
  @data
end

#expiration_timeObject

Returns the value of attribute expiration_time.



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

def expiration_time
  @expiration_time
end

#expiration_time_intervalObject

Returns the value of attribute expiration_time_interval.



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

def expiration_time_interval
  @expiration_time_interval
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#whereObject

Returns the value of attribute where.



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

def where
  @where
end

Instance Method Details

#saveObject



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

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!({ :type => @type }) if @type

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