lib/pmp/link.rb in pmp-0.1.3 vs lib/pmp/link.rb in pmp-0.2.0
- old
+ new
@@ -23,13 +23,13 @@
attr_accessor :parent
attr_accessor :params
- def initialize(parent=nil, link={})
+ def initialize(link={}, parent=nil)
super()
- self.parent = parent || PMP::CollectionDocument.new
+ self.parent = parent || link.delete('parent') || PMP::CollectionDocument.new
self.params = link.delete('params') || {}
# puts "params: #{params.inspect}"
parse_attributes(link)
[:href, :href_template, :method].each{|m| self.send("#{m}=", nil) unless respond_to?(m)}
end
@@ -39,10 +39,10 @@
attrs.delete(attrs[:href_template].blank? ? :href_template : :href)
attrs
end
def where(params={})
- self.class.new(parent, attributes.merge({'params'=>params}))
+ self.class.new(attributes.merge({'params'=>params}), parent)
end
def as_json
extract_attributes
end