Class: SimpleGCM::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_gcm/message.rb

Constant Summary collapse

ATTRIBUTES =
[:data, :collapse_key, :delay_while_idle, :time_to_live].freeze

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Message

Returns a new instance of Message.



7
8
9
10
11
12
13
14
# File 'lib/simple_gcm/message.rb', line 7

def initialize(args = {})
  @data = {}
  ATTRIBUTES.each do |attr|
    if (args.key?(attr))
      instance_variable_set("@#{attr}", args[attr])
    end
  end
end

Instance Method Details

#inspectObject



16
17
18
19
20
21
# File 'lib/simple_gcm/message.rb', line 16

def inspect
  ATTRIBUTES.inject({ }) do |h, attr|
    h[attr] = instance_variable_get("@#{attr}")
    h
  end
end

#to_jsonObject



23
24
25
# File 'lib/simple_gcm/message.rb', line 23

def to_json
  self.inspect.to_json
end