Class: AwesomeBotFactory::ExamplePayload

Inherits:
Hash
  • Object
show all
Defined in:
lib/awesome_bot_factory/example_payload.rb

Constant Summary collapse

DEFAULTS =
{
  "body" => "campfire message",
  "room_id" =>  "123456",
  "user_id" => "7890",
  "user" => {
    "name" => "Choco Bit", 
    "avatar_url" => "http://asset0.37img.com/global/.../avatar.png", 
    "type" => "Member", 
    "admin" => false
  },
  "user_name" => "choco",
  "match" => ["key:command value", "command", "value"],
  "slug" => "hexhash"
}

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ExamplePayload

Returns a new instance of ExamplePayload.



18
19
20
21
# File 'lib/awesome_bot_factory/example_payload.rb', line 18

def initialize(attributes={})
  self.merge!(DEFAULTS)
  self.merge!(attributes)
end

Instance Method Details

#as_hashObject



23
24
25
# File 'lib/awesome_bot_factory/example_payload.rb', line 23

def as_hash
  self
end

#as_jsonObject



27
28
29
# File 'lib/awesome_bot_factory/example_payload.rb', line 27

def as_json
  as_hash.to_json
end