Class: Pling::Message

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Message) initialize(body) - (Message) initialize(attributes)

Creates a new Pling::Message instance with the given body

Overloads:

  • - (Message) initialize(body)

    Parameters:

    • body (#to_s)
  • - (Message) initialize(attributes)

    Parameters:

    • attributes (Hash)

    Options Hash (attributes):

    • :body (#to_s)


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/pling/message.rb', line 76

def initialize(*args)
  attributes = case param = args.shift
    when String
      (args.last || {}).merge(:body => param)
    when Hash
      param
    else
      {}
  end

  attributes.each_pair do |key, value|
    method = "#{key}="
    send(method, value) if respond_to?(method)
  end
end

Instance Attribute Details

- (Object) badge - (Object) badge=(badge)

The message badge - not supported by all gateways

Overloads:

  • - (Object) badge=(badge)

    Parameters:

    • badge (#to_s)


35
36
37
# File 'lib/pling/message.rb', line 35

def badge
  @badge
end

- (Object) body - (Object) body=(body)

The message body

Overloads:

  • - (Object) body=(body)

    Parameters:

    • body (#to_s)


9
10
11
# File 'lib/pling/message.rb', line 9

def body
  @body
end

- (Object) payload - (Object) payload=(sound)

The message payload - not supported by all gateways

Overloads:

  • - (Object) payload=(sound)

    Parameters:

    • payload (#to_hash)


61
62
63
# File 'lib/pling/message.rb', line 61

def payload
  @payload
end

- (Object) sound - (Object) sound=(sound)

The message sound - not supported by all gateways

Overloads:

  • - (Object) sound=(sound)

    Parameters:

    • sound (#to_s)


48
49
50
# File 'lib/pling/message.rb', line 48

def sound
  @sound
end

- (Object) subject - (Object) subject=(subject)

The message subject - not supported by all gateways

Overloads:

  • - (Object) subject=(subject)

    Parameters:

    • subject (#to_s)


22
23
24
# File 'lib/pling/message.rb', line 22

def subject
  @subject
end

Instance Method Details

- (Pling::Message) to_pling_message

Returns the object itself as it is already a Pling::Message.

Returns:



104
105
106
# File 'lib/pling/message.rb', line 104

def to_pling_message
  self
end

- (Boolean) valid?

A message is valid if it has a body.

Returns:

  • (Boolean)


96
97
98
# File 'lib/pling/message.rb', line 96

def valid?
  !!body
end