Class: TxghServer::Webhooks::Git::DeleteAttributes

Inherits:
Object
  • Object
show all
Defined in:
lib/txgh-server/webhooks/git/delete_attributes.rb

Constant Summary collapse

ATTRIBUTES =
[
  :event, :repo_name, :ref, :ref_type
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DeleteAttributes

Returns a new instance of DeleteAttributes.



37
38
39
40
41
42
43
# File 'lib/txgh-server/webhooks/git/delete_attributes.rb', line 37

def initialize(options = {})
  ATTRIBUTES.each do |attr|
    instance_variable_set(
      "@#{attr}", options.fetch(attr) { options.fetch(attr.to_s) }
    )
  end
end

Class Method Details

.event(payload) ⇒ Object



18
19
20
# File 'lib/txgh-server/webhooks/git/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/git/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/git/delete_attributes.rb', line 26

def ref(payload)
  payload.fetch('ref')
end

.ref_type(payload) ⇒ Object

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/txgh-server/webhooks/git/delete_attributes.rb', line 30

def ref_type(payload)
  raise NotImplementedError
end

.repo_name(payload) ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/txgh-server/webhooks/git/delete_attributes.rb', line 22

def repo_name(payload)
  raise NotImplementedError
end

Instance Method Details

#to_hObject



45
46
47
48
49
# File 'lib/txgh-server/webhooks/git/delete_attributes.rb', line 45

def to_h
  ATTRIBUTES.each_with_object({}) do |attr, ret|
    ret[attr] = public_send(attr)
  end
end