Class: PactBroker::Webhooks::Repository
- Inherits:
-
Object
- Object
- PactBroker::Webhooks::Repository
show all
- Includes:
- Repositories
- Defined in:
- lib/pact_broker/webhooks/repository.rb
Instance Method Summary
collapse
#pact_repository, #pacticipant_repository, #tag_repository, #verification_repository, #version_repository, #webhook_repository
Instance Method Details
#create(uuid, webhook, consumer, provider) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/pact_broker/webhooks/repository.rb', line 15
def create uuid, webhook, consumer, provider
db_webhook = Webhook.from_domain webhook, consumer, provider
db_webhook.uuid = uuid
db_webhook.save
webhook.request..each_pair do | name, value |
db_webhook. PactBroker::Webhooks::WebhookHeader.from_domain(name, value, db_webhook.id)
end
find_by_uuid db_webhook.uuid
end
|
#delete_by_pacticipant(pacticipant) ⇒ Object
33
34
35
36
|
# File 'lib/pact_broker/webhooks/repository.rb', line 33
def delete_by_pacticipant pacticipant
Webhook.where(consumer_id: pacticipant.id).destroy
Webhook.where(provider_id: pacticipant.id).destroy
end
|
#delete_by_uuid(uuid) ⇒ Object
29
30
31
|
# File 'lib/pact_broker/webhooks/repository.rb', line 29
def delete_by_uuid uuid
Webhook.where(uuid: uuid).destroy
end
|
#find_all ⇒ Object
38
39
40
|
# File 'lib/pact_broker/webhooks/repository.rb', line 38
def find_all
Webhook.all.collect(&:to_domain)
end
|
#find_by_consumer_and_provider(consumer, provider) ⇒ Object
42
43
44
|
# File 'lib/pact_broker/webhooks/repository.rb', line 42
def find_by_consumer_and_provider consumer, provider
Webhook.where(consumer_id: consumer.id, provider_id: provider.id).collect(&:to_domain)
end
|
#find_by_uuid(uuid) ⇒ Object
25
26
27
|
# File 'lib/pact_broker/webhooks/repository.rb', line 25
def find_by_uuid uuid
Webhook.where(uuid: uuid).limit(1).collect(&:to_domain)[0]
end
|