Class: PostReceivePayload
- Inherits:
-
Object
- Object
- PostReceivePayload
- Defined in:
- app/models/post_receive_payload.rb
Instance Attribute Summary collapse
-
#agent_email ⇒ Object
Returns the value of attribute agent_email.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#commit ⇒ Object
Returns the value of attribute commit.
Instance Method Summary collapse
-
#initialize(params) ⇒ PostReceivePayload
constructor
A new instance of PostReceivePayload.
- #parse_github_style_agent(pusher) ⇒ Object
- #parse_github_style_params(params) ⇒ Object
- #parse_params(params) ⇒ Object
- #parsed? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ PostReceivePayload
Returns a new instance of PostReceivePayload.
3 4 5 |
# File 'app/models/post_receive_payload.rb', line 3 def initialize(params) parse_params(params) end |
Instance Attribute Details
#agent_email ⇒ Object
Returns the value of attribute agent_email.
7 8 9 |
# File 'app/models/post_receive_payload.rb', line 7 def agent_email @agent_email end |
#branch ⇒ Object
Returns the value of attribute branch.
7 8 9 |
# File 'app/models/post_receive_payload.rb', line 7 def branch @branch end |
#commit ⇒ Object
Returns the value of attribute commit.
7 8 9 |
# File 'app/models/post_receive_payload.rb', line 7 def commit @commit end |
Instance Method Details
#parse_github_style_agent(pusher) ⇒ Object
24 25 26 27 28 |
# File 'app/models/post_receive_payload.rb', line 24 def parse_github_style_agent(pusher) return nil unless pusher && pusher.key?("email") return pusher["email"] unless pusher.key?("name") "#{pusher["name"].inspect} <#{pusher["email"]}>" end |
#parse_github_style_params(params) ⇒ Object
18 19 20 21 22 |
# File 'app/models/post_receive_payload.rb', line 18 def parse_github_style_params(params) self.commit = params["after"] self.agent_email = parse_github_style_agent(params["pusher"]) self.branch = params["ref"].split("/").last if params.key?("ref") end |
#parse_params(params) ⇒ Object
13 14 15 16 |
# File 'app/models/post_receive_payload.rb', line 13 def parse_params(params) (params = MultiJson.load(params["payload"])) if params.key?("payload") parse_github_style_params(params) if params end |
#parsed? ⇒ Boolean
9 10 11 |
# File 'app/models/post_receive_payload.rb', line 9 def parsed? commit.present? end |