lib/troo/presenters/comment.rb in troo-0.0.8 vs lib/troo/presenters/comment.rb in troo-0.0.9

- old
+ new

@@ -1,38 +1,52 @@ module Troo module Presenters class Comment include DecoratorHelpers - class << self - def show(card, options = {}) - new(card, options).show - end - end - def initialize(card, options = {}) - @card = card - @options = options + @card, @options = card, options end def show - spacing do - print card.decorator.short + title - print_error 'No comments were found.' unless comments.any? - - comments.each do |comment| - indent { print comment.decorator.as_view } - end + if comments? + all_comments + else + no_comments end end private attr_reader :card + def output + @output ||= Troo::Output.new + end + + def all_comments + comments.map do |comment| + output.render comment.decorator.as_view + end + nil + end + + def no_comments + output.render error('No comments were found.') + end + + def comments? + comments.any? + end + def comments - card.comments + @comments ||= card.comments + end + + def title + output.render card.decorator.title + "\n" end end end end