lib/recurly/resource.rb in recurly-2.5.1 vs lib/recurly/resource.rb in recurly-2.5.2
- old
+ new
@@ -112,13 +112,13 @@
# If you want to iterate over _every_ record, a convenience method will
# automatically paginate:
#
# Account.find_each { |account| p account }
class Resource
- autoload :Errors, 'recurly/resource/errors'
- autoload :Pager, 'recurly/resource/pager'
- autoload :Association, 'recurly/resource/association'
+ require 'recurly/resource/errors'
+ require 'recurly/resource/pager'
+ require 'recurly/resource/association'
# Raised when a record cannot be found.
#
# @example
# begin
@@ -314,10 +314,16 @@
# @raise [API::NotModified] If the <tt>:etag</tt> option is set and
# matches the server's.
# @example
# Recurly::Account.find "heisenberg"
# # => #<Recurly::Account account_code: "heisenberg", ...>
+ # Use the following identifiers for these types of objects:
+ # for accounts use account_code
+ # for plans use plan_code
+ # for invoices use invoice_number
+ # for subscriptions use uuid
+ # for transactions use uuid
def find uuid, options = {}
if uuid.nil?
# Should we raise an ArgumentError, instead?
raise NotFound, "can't find a record with nil identifier"
end
@@ -399,10 +405,15 @@
:method => el.attribute('method').to_s,
:href => el.attribute('href').value
}
next
end
-
+
+ # Nokogiri on Jruby-1.7.19 likes to throw NullPointer exceptions
+ # if you try to run certian operations like el.attribute(''). Since
+ # we dont care about text nodes, let's just skip them
+ next if defined?(Nokogiri::XML::Node::TEXT_NODE) && el.node_type == Nokogiri::XML::Node::TEXT_NODE
+
if el.children.empty? && href = el.attribute('href')
klass_name = Helper.classify(klass.association_class_name(el.name) ||
el.attribute('type') ||
el.name)