Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Hashie:Mash instead of ObjectifiedHash #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gitlab.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]

gem.add_runtime_dependency 'httparty'
gem.add_runtime_dependency 'hashie'

gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
Expand Down
1 change: 0 additions & 1 deletion lib/gitlab.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require File.expand_path('../gitlab/version', __FILE__)
require File.expand_path('../gitlab/objectified_hash', __FILE__)
require File.expand_path('../gitlab/configuration', __FILE__)
require File.expand_path('../gitlab/error', __FILE__)
require File.expand_path('../gitlab/request', __FILE__)
Expand Down
18 changes: 0 additions & 18 deletions lib/gitlab/objectified_hash.rb

This file was deleted.

7 changes: 4 additions & 3 deletions lib/gitlab/request.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
require 'httparty'
require 'hashie/mash'

module Gitlab
# @private
class Request
include HTTParty
format :json
headers 'Accept' => 'application/json'
parser Proc.new {|body| parse(body)}
parser Proc.new {|body, _| parse(body)}

# Converts the response body to an ObjectifiedHash.
def self.parse(body)
body = decode(body)

if body.is_a? Hash
ObjectifiedHash.new body
Hashie::Mash.new body
elsif body.is_a? Array
body.collect! {|e| ObjectifiedHash.new(e)}
body.collect! {|e| Hashie::Mash.new(e)}
else
raise Error::Parsing.new "Couldn't parse a response body"
end
Expand Down