Class: Github::PullRequestEvent
- Defined in:
- app/models/github/pull_request_event.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#pull_request ⇒ Object
readonly
Returns the value of attribute pull_request.
Attributes inherited from Event
Instance Method Summary collapse
Methods inherited from Event
Constructor Details
#initialize(payload) ⇒ PullRequestEvent
8 9 10 11 12 13 |
# File 'app/models/github/pull_request_event.rb', line 8 def initialize(payload) super @action = payload.fetch "action" @pull_request = payload.fetch "pull_request" @actor = payload.fetch("sender", {})["login"] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
5 6 7 |
# File 'app/models/github/pull_request_event.rb', line 5 def action @action end |
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
5 6 7 |
# File 'app/models/github/pull_request_event.rb', line 5 def actor @actor end |
#pull_request ⇒ Object (readonly)
Returns the value of attribute pull_request.
5 6 7 |
# File 'app/models/github/pull_request_event.rb', line 5 def pull_request @pull_request end |
Instance Method Details
#process! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/github/pull_request_event.rb', line 15 def process! Rails.logger.info "\e[34m[github] Processing Pull Request Event (action: #{action})\e[0m" # Ignore when pull requests are assigned if action == "assigned" || action == "unassigned" return end # Delete pull requests when they are closed if action == "closed" PullRequest.close! pull_request, as: actor return end # Ensure that we have a record of this open pull request # action: labeled, unlabeled, opened, reopened, or synchronized pr = PullRequest.upsert! pull_request, as: actor # The Pull Request may be invalid if it isn't for a # project that exists in Houston. return unless pr && pr.persisted? case action when "labeled" then pr.add_label! payload["label"]["name"], as: actor when "unlabeled" then pr.remove_label! payload["label"]["name"], as: actor end end |