Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Use Hash[] instead of DataMapper::Ext::Array.to_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
dkubb committed Mar 23, 2011
1 parent ee08a69 commit 2cb5be4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/dm-serializer/to_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def to_json(*args)
module ValidationErrors
module ToJson
def to_json(*args)
DataMapper::Ext::Array.to_hash(errors).to_json
Hash[ errors ].to_json
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dm-serializer/to_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def to_yaml(opts_or_emitter = {})
module ValidationErrors
module ToYaml
def to_yaml(*args)
DataMapper::Ext::Array.to_hash(errors).to_yaml(*args)
Hash[ errors ].to_yaml(*args)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/serialization_method_shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
keys = %w[ id composite name breed ]

resources = [
keys.zip([ 1, 2, 'Betsy', 'Jersey' ]).to_hash,
keys.zip([ 89, 34, 'Berta', 'Guernsey' ]).to_hash,
Hash[ keys.zip([ 1, 2, 'Betsy', 'Jersey' ]) ],
Hash[ keys.zip([ 89, 34, 'Berta', 'Guernsey' ]) ],
]

collection = DataMapper::Collection.new(query, query.model.load(resources, query))
Expand Down Expand Up @@ -183,8 +183,8 @@
keys = %w[ id composite name breed ]

resources = [
keys.zip([ 1, 2, 'Betsy', 'Jersey' ]).to_hash,
keys.zip([ 10, 20, 'Berta', 'Guernsey' ]).to_hash,
Hash[ keys.zip([ 1, 2, 'Betsy', 'Jersey' ]) ],
Hash[ keys.zip([ 10, 20, 'Berta', 'Guernsey' ]) ],
]

collection = DataMapper::Collection.new(query, query.model.load(resources, query))
Expand Down
4 changes: 2 additions & 2 deletions spec/public/to_json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
keys = %w[ id composite name breed ]

resources = [
keys.zip([ 1, 2, 'Betsy', 'Jersey' ]).to_hash,
keys.zip([ 10, 20, 'Berta', 'Guernsey' ]).to_hash,
Hash[ keys.zip([ 1, 2, 'Betsy', 'Jersey' ]) ],
Hash[ keys.zip([ 10, 20, 'Berta', 'Guernsey' ]) ],
]

@collection = DataMapper::Collection.new(query, query.model.load(resources, query))
Expand Down
6 changes: 0 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

require File.expand_path('spec/lib/serialization_method_shared_spec')

class Array
def to_hash
DataMapper::Ext::Array.to_hash(self)
end
end

# require fixture resources
SPEC_ROOT = Pathname(__FILE__).dirname.expand_path
Pathname.glob((SPEC_ROOT + 'fixtures/**/*.rb').to_s).each { |file| require file }
Expand Down

0 comments on commit 2cb5be4

Please sign in to comment.