lib/hyper_resource.rb in hyperresource-0.1.9.3 vs lib/hyper_resource.rb in hyperresource-0.1.9.4

- old
+ new

@@ -1,8 +1,12 @@ -this_dir = File.dirname(File.absolute_path(__FILE__)) +this_dir = File.dirname(__FILE__) Dir.glob(this_dir + '/hyper_resource/**/*.rb') {|f| require f} +if RUBY_VERSION[0..2] == '1.8' + require 'rubygems' +end + require 'pp' class HyperResource include HyperResource::Modules::Utils include HyperResource::Modules::HTTP @@ -147,11 +151,11 @@ ## Override with care. def method_missing(method, *args) self.get unless self.loaded method = method.to_s - if method[-1] == '=' + if method[-1,1] == '=' return attributes[method[0..-2]] = args.first if attributes[method[0..-2]] else return attributes[method] if attributes && attributes[method] return objects[method] if objects && objects[method] if links && links[method] @@ -247,11 +251,11 @@ ## Override this method in a subclass to alter HyperResource's behavior. def self._get_response_data_type(response) # :nodoc: return nil unless response return nil unless content_type = response['content-type'] - return nil unless m=content_type.match(/;\s* type=(?<type> [0-9A-Za-z:]+)/x) - m[:type][0].upcase + m[:type][1..-1] + return nil unless m=content_type.match(/;\s* type=([0-9A-Za-z:]+)/x) + m[1][0,1].upcase + m[1][1..-1] end def _get_response_data_type # :nodoc: self.class._get_response_data_type(self.response) end