class OData::Helpers
Helper methods
Public Class Methods
get_namespaced_attribute(node, attr_name, prefix)
click to toggle source
Nokogiri changed how it handles namespaced attributes with v1.5.1, this is for backwards compatibility to >= 1.4.2 Nokogiri now >=1.5.1 requires the namespace prefix is used
# File lib/ruby_odata/helpers.rb, line 23 def self.get_namespaced_attribute(node, attr_name, prefix) return node["#{prefix}:#{attr_name}"] || node[attr_name] end
normalize_to_hash(val)
click to toggle source
Helper to normalize the results of a select result; Ruby 1.9 Hash.select returns a Hash, 1.8 returns an Array This is for Ruby 1.8 support, but should be removed in the future
# File lib/ruby_odata/helpers.rb, line 6 def self.normalize_to_hash(val) return nil if val.nil? (val.is_a? Hash) ? val : Hash[*val.flatten] end
uri_escape(*args)
click to toggle source
Wrapper for URI escaping that switches between URI::Parser#escape and URI.escape for 1.9-compatibility (thanks FakeWeb github.com/chrisk/fakeweb/blob/master/lib/fake_web/utility.rb#L40)
# File lib/ruby_odata/helpers.rb, line 13 def self.uri_escape(*args) if URI.const_defined?(:Parser) URI::Parser.new.escape(*args) else URI.escape(*args) end end