Sha256: 89759e56f3f53c85254e9f4e6ed22f0dd41ef3255cdc59572bad2a2c24899d88

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

=begin
  Camaleon CMS is a content management system
  Copyright (C) 2015 by Owen Peredo Diaz
  Email: owenperedo@gmail.com
  This program is free software: you can redistribute it and/or modify   it under the terms of the GNU Affero General Public License as  published by the Free Software Foundation, either version 3 of the  License, or (at your option) any later version.
  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the  GNU Affero General Public License (GPLv3) for more details.
=end
class CamaleonCms::PostCommentDecorator < Draper::Decorator
  delegate_all

  # return created at date formatted
  def the_created_at(format = :long)
    h.l(object.created_at, format: format.to_sym)
  end

  # return owner of this comment
  def the_user
    object.user.decorate
  end
  alias_method :the_author, :the_user

  def the_post
    object.post.decorate
  end

  def the_content
    object.content
  end

  def the_answers
    object.children.approveds
  end

  def the_author_name
    object.author.presence || object.user.full_name
  end

  def the_author_email
    object.author_email.presence || object.user.email
  end

  def the_author_url
    object.author_url.presence || (object.user.username == 'anonymous' ? '' : object.user.decorate.the_url)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
camaleon_cms-2.2.1 app/decorators/camaleon_cms/post_comment_decorator.rb
camaleon_cms-2.2.0 app/decorators/camaleon_cms/post_comment_decorator.rb