From 25828029a92a4268a8440d4ed41809baddb598fc Mon Sep 17 00:00:00 2001 From: guilherme silveira Date: Sun, 24 Oct 2010 11:16:10 -0200 Subject: [PATCH] changed return if unless --- .../common/representation/atom/base.rb | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/lib/restfulie/common/representation/atom/base.rb b/lib/restfulie/common/representation/atom/base.rb index 64d347ad..a9bd80d8 100644 --- a/lib/restfulie/common/representation/atom/base.rb +++ b/lib/restfulie/common/representation/atom/base.rb @@ -84,55 +84,54 @@ def rights=(value) # Author have name, and optional uri and email, this describes a person def authors - unless @authors - @authors = TagCollection.new(@doc) - @doc.xpath("xmlns:author").each do |author| - @authors << Person.new("author", author) - end + return @authors if @authors + + @authors = TagCollection.new(@doc) + @doc.xpath("xmlns:author").each do |author| + @authors << Person.new("author", author) end + @authors - return @authors end def contributors - unless @contributors - @contributors = TagCollection.new(@doc) - @doc.xpath("xmlns:author").each do |contributor| - @contributors << Person.new("contributor", contributor) - end + return @contributors if @contributors + + @contributors = TagCollection.new(@doc) + @doc.xpath("xmlns:author").each do |contributor| + @contributors << Person.new("contributor", contributor) end - - return @contributor + @contributors end # It has one required attribute, href, and five optional attributes: rel, type, hreflang, title, and length def links - unless @links - @links = TagCollection.new(@doc) do |array, symbol, *args| - linkset = array.select {|link| link.rel == symbol.to_s } - unless linkset.empty? - linkset.size == 1 ? linkset.first : linkset - else - nil - end - end - @doc.xpath("xmlns:link").each do |link| - @links << Link.new(link) - end + return @links if @links + + @links = TagCollection.new(@doc) do |array, symbol, *args| + linkset = array.select {|link| link.rel == symbol.to_s } + unless linkset.empty? + linkset.size == 1 ? linkset.first : linkset + else + nil + end end + @doc.xpath("xmlns:link").each do |link| + @links << Link.new(link) + end + @links - return @links end def categories - unless @categories - @categories = TagCollection.new(@doc) - @doc.xpath("xmlns:category").each do |category| - @categories << Link.new(category) - end - end + return @categories if @categories + + @categories = TagCollection.new(@doc) + @doc.xpath("xmlns:category").each do |category| + @categories << Link.new(category) + end + @categories - return @categories end end end