Permalink
Browse files

Refactoring:Extracted map_into_query_field method

  • Loading branch information...
1 parent bff1047 commit eacbd750a58ea04cddb617b92ee00e344274163b Makoto Inoue committed Nov 11, 2008
Showing with 7 additions and 8 deletions.
  1. +7 −8 lib/tc_adapter.rb
View
@@ -44,11 +44,7 @@ def read_many(query)
Collection.new(query) do |collection|
results.each do |result|
-
- data = query.fields.map do |property|
- result[property.field.to_sym]
- end
-
+ data = map_into_query_field(query, result)
collection.load(data)
end
end
@@ -59,9 +55,7 @@ def read_one(query)
data = (results.class == Array ? results.first : results)
if data
- data = query.fields.map do |property|
- data[property.field.to_sym]
- end
+ data = map_into_query_field(query, data)
query.model.load(data, query)
end
end
@@ -171,6 +165,11 @@ def parse_query(query)
results
end
+ def map_into_query_field(query, data)
+ query.fields.map do |property|
+ data[property.field.to_sym]
+ end
+ end
end # class AbstractAdapter
end # module Adapters
end # module DataMapper

0 comments on commit eacbd75

Please sign in to comment.