Class: Policial::PullRequestEvent
- Inherits:
-
Object
- Object
- Policial::PullRequestEvent
- Defined in:
- lib/policial/pull_request_event.rb
Overview
Public: Parses a pull request event payload.
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(payload) ⇒ PullRequestEvent
constructor
A new instance of PullRequestEvent.
- #pull_request ⇒ Object
- #should_investigate? ⇒ Boolean
Constructor Details
#initialize(payload) ⇒ PullRequestEvent
Returns a new instance of PullRequestEvent.
8 9 10 |
# File 'lib/policial/pull_request_event.rb', line 8 def initialize(payload) @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
6 7 8 |
# File 'lib/policial/pull_request_event.rb', line 6 def payload @payload end |
Instance Method Details
#pull_request ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/policial/pull_request_event.rb', line 12 def pull_request @pull_request ||= PullRequest.new( repo: @payload['repository']['full_name'], number: @payload['number'], head_sha: @payload['pull_request']['head']['sha'], user: @payload['pull_request']['user']['login'] ) rescue NoMethodError nil end |
#should_investigate? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/policial/pull_request_event.rb', line 23 def should_investigate? !pull_request.nil? && ( @payload['action'] == 'opened' || @payload['action'] == 'synchronize' ) end |