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_attributes ⇒ Object
- #should_investigate? ⇒ Boolean
Constructor Details
#initialize(payload) ⇒ PullRequestEvent
Returns a new instance of PullRequestEvent.
10 11 12 |
# File 'lib/policial/pull_request_event.rb', line 10 def initialize(payload) @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
8 9 10 |
# File 'lib/policial/pull_request_event.rb', line 8 def payload @payload end |
Instance Method Details
#pull_request_attributes ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/policial/pull_request_event.rb', line 14 def pull_request_attributes { 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
25 26 27 28 29 |
# File 'lib/policial/pull_request_event.rb', line 25 def should_investigate? !pull_request_attributes.nil? && ( @payload['action'] == 'opened' || @payload['action'] == 'synchronize' ) end |