lib/flexirest/request.rb in flexirest-1.6.3 vs lib/flexirest/request.rb in flexirest-1.6.4
- old
+ new
@@ -6,10 +6,11 @@
module Flexirest
class Request
include AttributeParsing
include JsonAPIProxy
+ include ActiveSupport::Inflector
attr_accessor :post_params, :get_params, :url, :path, :headers, :method, :object, :body, :forced_url, :original_url, :retrying
def initialize(method, object, params = {})
@method = method
@method[:options] ||= {}
@@ -582,11 +583,15 @@
if hal_response? && name.nil?
attributes = handle_hal_links_embedded(object, attributes)
end
attributes.each do |k,v|
- k = k.to_sym
+ if @method[:options][:rubify_names]
+ k = rubify_name(k)
+ else
+ k = k.to_sym
+ end
overridden_name = select_name(k, overridden_name)
if @method[:options][:lazy].include?(k)
object._attributes[k] = Flexirest::LazyAssociationLoader.new(overridden_name, v, self, overridden_name:(overridden_name))
elsif v.is_a? Hash
object._attributes[k] = new_object(v, overridden_name )
@@ -753,9 +758,13 @@
result << iterator
else
result << new_object(json_object, @overridden_name)
end
end
+ end
+
+ def rubify_name(k)
+ k.underscore.to_sym
end
end
class RequestException < StandardError ; end