lib/pmp/parser.rb in pmp-0.1.1 vs lib/pmp/parser.rb in pmp-0.1.2
- old
+ new
@@ -9,13 +9,10 @@
result = {}
result['version'] = self.version
result['links'] = extract_links
result['attributes'] = extract_attributes
- # more elegant?
- result['attributes'].delete('items')
-
result
end
def extract_attributes(obj=self)
obj.attributes.inject({}) do |result, pair|
@@ -72,22 +69,19 @@
end
end
end
def parse_link(name, info)
-
- return parse_query_links(info) if (name.to_s == 'query')
-
if !info.is_a?(Array)
Link.new(self, info)
elsif info.size == 1
Link.new(self, info.first)
elsif info.size > 0
- info.map{|l| Link.new(self, l)}
+ parse_links_list(info)
end
end
- def parse_query_links(links)
+ def parse_links_list(links)
links.inject({}) do |results, query|
rel = query['rels'].first
results[rel] = Link.new(self, query)
results
end