Skip to content

Commit

Permalink
Remove ActiveSupport::OrderedHash usage.
Browse files Browse the repository at this point in the history
Minus one ActiveSupport dependency!
OrderedHash is a hash that preserves insertion order. It's a legacy
stuff since Ruby >= 1.9 already preserves insertion order.
  • Loading branch information
marshall-lee committed Aug 25, 2015
1 parent c8b657e commit 99fabb8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion lib/grape.rb
Expand Up @@ -9,7 +9,6 @@
require 'set'
require 'active_support/version'
require 'active_support/core_ext/hash/indifferent_access'
require 'active_support/ordered_hash'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/array/extract_options'
require 'active_support/core_ext/hash/deep_merge'
Expand Down
2 changes: 1 addition & 1 deletion lib/grape/dsl/configuration.rb
Expand Up @@ -98,7 +98,7 @@ def unset_description_field(field)
# Merge multiple layers of settings into one hash.
def stacked_hash_to_hash(settings)
return nil if settings.nil? || settings.blank?
settings.each_with_object(ActiveSupport::OrderedHash.new) { |value, result| result.deep_merge!(value) }
settings.each_with_object({}) { |value, result| result.deep_merge!(value) }
end

# Returns an object which configures itself via an instance-context DSL.
Expand Down
16 changes: 8 additions & 8 deletions lib/grape/util/content_types.rb
@@ -1,18 +1,18 @@
module Grape
module ContentTypes
# Content types are listed in order of preference.
CONTENT_TYPES = ActiveSupport::OrderedHash[
:xml, 'application/xml',
:serializable_hash, 'application/json',
:json, 'application/json',
:binary, 'application/octet-stream',
:txt, 'text/plain'
]
CONTENT_TYPES = {
xml: 'application/xml',
serializable_hash: 'application/json',
json: 'application/json',
binary: 'application/octet-stream',
txt: 'text/plain'
}

def self.content_types_for_settings(settings)
return nil if settings.nil? || settings.blank?

settings.each_with_object(ActiveSupport::OrderedHash.new) { |value, result| result.merge!(value) }
settings.each_with_object({}) { |value, result| result.merge!(value) }
end

def self.content_types_for(from_settings)
Expand Down
8 changes: 4 additions & 4 deletions spec/grape/api_spec.rb
Expand Up @@ -2812,10 +2812,10 @@ def serializable_hash
end
it 'hash' do
subject.get '/example' do
ActiveSupport::OrderedHash[
:example1, 'example1',
:example2, 'example2'
]
{
example1: 'example1',
example2: 'example2'
}
end
get '/example'
expect(last_response.status).to eq(200)
Expand Down

0 comments on commit 99fabb8

Please sign in to comment.