lib/apidiesel/dsl.rb in apidiesel-0.9 vs lib/apidiesel/dsl.rb in apidiesel-0.10
- old
+ new
@@ -367,11 +367,11 @@
#
# expects do
# integer :order_id
# datetime :ordered_at
#
- # an_array_of :products do
+ # array :products do
# string :name
# integer :product_id
# end
# end
#
@@ -388,11 +388,11 @@
# # },
# # ]
#
# @example
# expects do
- # an_array_of do
+ # array do
# string :name
# integer :order_id
# end
# end
#
@@ -408,11 +408,11 @@
end
args = normalize_arguments(args, kargs)
response_formatters << lambda do |data, processed_data|
- data = get_value(data, args[:at])
+ data = get_value(data, args[:at]) if args[:at]
return processed_data unless data.present?
data = [data] if data.is_a?(Hash)
@@ -436,12 +436,15 @@
result = apply_filter(args[:postfilter_each] || args[:filter_each], result)
result
end
- processed_data[ args[:as] ] = array_of_hashes.compact
-
- processed_data
+ if args[:as]
+ processed_data[ args[:as] ] = array_of_hashes.compact
+ processed_data
+ else
+ array_of_hashes.compact
+ end
end
end
# Returns `key` from the API response as a hash.
#
\ No newline at end of file