Skip to content

Commit

Permalink
Use the klass that is instantiated associations when building a resou…
Browse files Browse the repository at this point in the history
…rce from xml
  • Loading branch information
cbarton committed Jun 25, 2015
1 parent ab3fbc0 commit c6ebc9b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/recurly/resource.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'pry'
require 'date'
require 'erb'

Expand Down Expand Up @@ -404,15 +405,15 @@ def from_xml xml

if el.children.empty? && href = el.attribute('href')
resource_class = Recurly.const_get(
Helper.classify(association_class_name(el.name) ||
Helper.classify(klass.association_class_name(el.name) ||
el.attribute('type') || el.name), false
)
case el.name
when *associations_for_relation(:has_many)
when *klass.associations_for_relation(:has_many)
record[el.name] = Pager.new(
resource_class, :uri => href.value, :parent => record
)
when *(associations_for_relation(:has_one) + associations_for_relation(:belongs_to))
when *(klass.associations_for_relation(:has_one) + klass.associations_for_relation(:belongs_to))
record.links[el.name] = {
:resource_class => resource_class,
:method => :get,
Expand Down

0 comments on commit c6ebc9b

Please sign in to comment.