Class: TxghServer::Webhooks::Github::DeleteAttributes
- Inherits:
-
Object
- Object
- TxghServer::Webhooks::Github::DeleteAttributes
- Defined in:
- lib/txgh-server/webhooks/github/delete_attributes.rb
Constant Summary collapse
- ATTRIBUTES =
[ :event, :repo_name, :ref, :ref_type ]
Class Method Summary collapse
- .event(payload) ⇒ Object
- .from_webhook_payload(payload) ⇒ Object
- .ref(payload) ⇒ Object
- .ref_type(payload) ⇒ Object
- .repo_name(payload) ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DeleteAttributes
constructor
A new instance of DeleteAttributes.
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DeleteAttributes
Returns a new instance of DeleteAttributes.
37 38 39 40 41 42 43 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 37 def initialize( = {}) ATTRIBUTES.each do |attr| instance_variable_set( "@#{attr}", .fetch(attr) { .fetch(attr.to_s) } ) end end |
Class Method Details
.event(payload) ⇒ Object
18 19 20 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 18 def event(payload) 'delete' end |
.from_webhook_payload(payload) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 10 def from_webhook_payload(payload) new( ATTRIBUTES.each_with_object({}) do |attr, ret| ret[attr] = public_send(attr, payload) end ) end |
.ref(payload) ⇒ Object
26 27 28 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 26 def ref(payload) payload.fetch('ref') end |
.ref_type(payload) ⇒ Object
30 31 32 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 30 def ref_type(payload) payload.fetch('ref_type') end |
.repo_name(payload) ⇒ Object
22 23 24 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 22 def repo_name(payload) payload.fetch('repository').fetch('full_name') end |
Instance Method Details
#to_h ⇒ Object
45 46 47 48 49 |
# File 'lib/txgh-server/webhooks/github/delete_attributes.rb', line 45 def to_h ATTRIBUTES.each_with_object({}) do |attr, ret| ret[attr] = public_send(attr) end end |