ChuckJHardy/GitWebHookModel

View on GitHub
lib/git_web_hook_model/parse.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'json'

class GitWebHookModel
  class Parse
    def initialize(response)
      @response = response
    end

    def as_hash
      hash? ? @response : parsed_response
    end

    private

    def hash?
      @response.is_a?(Hash)
    end

    def parsed_response
      JSON.parse(@response)
    end
  end
end