lib/amee/profile_item.rb in amee-4.3.2 vs lib/amee/profile_item.rb in amee-4.4.0
- old
+ new
@@ -1,8 +1,11 @@
# Copyright (C) 2008-2011 AMEE UK Ltd. - http://www.amee.com
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
+require 'active_support/core_ext/hash/conversions'
+require 'active_support/inflector'
+
module AMEE
module Profile
class Item < AMEE::Profile::Object
def initialize(data = {})
@@ -312,12 +315,12 @@
options.merge! :dataItemUid => data_item_uid
# POST
response = connection.post(path, options)
# Parse response
category = response.body.empty? ? nil : Category.parse(connection, response.body, options)
- if response['Location']
- location = response['Location'].match("https??://.*?(/.*)")[1]
+ if response.headers_hash.has_key?('Location') && response.headers_hash['Location']
+ location = response.headers_hash['Location'].match("https??://.*?(/.*)")[1]
else
location = category.full_path + "/" + category.items[0][:path]
end
if get_item == true
if connection.version >= 2
@@ -333,9 +336,10 @@
values = []
item[:values].each do |k,v|
values << v.merge(:path => k.to_s)
end
item[:values] = values
+ item[:path] = category.path + '/' + item[:path]
return AMEE::Profile::Item.new(item)
else
get_options = {}
get_options[:returnUnit] = options[:returnUnit] if options[:returnUnit]
get_options[:returnPerUnit] = options[:returnPerUnit] if options[:returnPerUnit]