Class: Pinch::Webhook
- Inherits:
-
Object
- Object
- Pinch::Webhook
- Defined in:
- lib/pinch/models/webhook.rb
Instance Attribute Summary collapse
-
#id ⇒ Integer
readonly
TODO: Write general description for this method.
-
#url ⇒ String
TODO: Write general description for this method.
-
#webhook_type ⇒ Integer
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
Instance Method Summary collapse
-
#initialize(id = nil, url = nil, webhook_type = nil) ⇒ Webhook
constructor
A new instance of Webhook.
-
#key_map ⇒ Object
Defines the key map for json serialization.
- #method_missing(method_name) ⇒ Object
-
#to_json ⇒ Object
Creates JSON of the curent object.
Constructor Details
#initialize(id = nil, url = nil, webhook_type = nil) ⇒ Webhook
Returns a new instance of Webhook.
18 19 20 21 22 23 24 25 |
# File 'lib/pinch/models/webhook.rb', line 18 def initialize(id = nil, url = nil, webhook_type = nil) @id = id @url = url @webhook_type = webhook_type end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
27 28 29 |
# File 'lib/pinch/models/webhook.rb', line 27 def method_missing(method_name) puts "There is no method called '#{method_name}'." end |
Instance Attribute Details
#id ⇒ Integer (readonly)
TODO: Write general description for this method
8 9 10 |
# File 'lib/pinch/models/webhook.rb', line 8 def id @id end |
#url ⇒ String
TODO: Write general description for this method
12 13 14 |
# File 'lib/pinch/models/webhook.rb', line 12 def url @url end |
#webhook_type ⇒ Integer
TODO: Write general description for this method
16 17 18 |
# File 'lib/pinch/models/webhook.rb', line 16 def webhook_type @webhook_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pinch/models/webhook.rb', line 38 def self.from_hash(hash) if hash == nil nil else # Extract variables from the hash id = hash["id"] url = hash["url"] webhook_type = hash["webhook_type"] # Create object from extracted values Webhook.new(id, url, webhook_type) end end |
Instance Method Details
#key_map ⇒ Object
Defines the key map for json serialization
54 55 56 57 58 59 60 |
# File 'lib/pinch/models/webhook.rb', line 54 def key_map hash = {} hash['id'] = id hash['url'] = url hash['webhook_type'] = webhook_type hash end |
#to_json ⇒ Object
Creates JSON of the curent object
32 33 34 35 |
# File 'lib/pinch/models/webhook.rb', line 32 def to_json hash = key_map hash.to_json end |