Skip to content

Commit

Permalink
changed return if unless
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Oct 24, 2010
1 parent 57caceb commit 2582802
Showing 1 changed file with 32 additions and 33 deletions.
65 changes: 32 additions & 33 deletions lib/restfulie/common/representation/atom/base.rb
Expand Up @@ -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
Expand Down

0 comments on commit 2582802

Please sign in to comment.