Class: Pinch::WebhookType

Inherits:
Object
  • Object
show all
Defined in:
lib/pinch/models/webhook_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil, name = nil) ⇒ WebhookType

Returns a new instance of WebhookType.



14
15
16
17
18
19
# File 'lib/pinch/models/webhook_type.rb', line 14

def initialize(id = nil,
               name = nil)
  @id = id
  @name = name

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ Object



21
22
23
# File 'lib/pinch/models/webhook_type.rb', line 21

def method_missing(method_name)
  puts "There is no method called '#{method_name}'."
end

Instance Attribute Details

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


8
9
10
# File 'lib/pinch/models/webhook_type.rb', line 8

def id
  @id
end

#nameString

TODO: Write general description for this method

Returns:



12
13
14
# File 'lib/pinch/models/webhook_type.rb', line 12

def name
  @name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pinch/models/webhook_type.rb', line 32

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    id = hash["id"]
    name = hash["name"]
    # Create object from extracted values
    WebhookType.new(id,
                    name)
  end
end

Instance Method Details

#key_mapObject

Defines the key map for json serialization



46
47
48
49
50
51
# File 'lib/pinch/models/webhook_type.rb', line 46

def key_map
  hash = {}
  hash['id'] = id
  hash['name'] = name
  hash
end

#to_jsonObject

Creates JSON of the curent object



26
27
28
29
# File 'lib/pinch/models/webhook_type.rb', line 26

def to_json
  hash = key_map
  hash.to_json
end