Sha256: 1348a714f4e74f52af28322ae38c06b6fdc7b45af819401c56da533060f849d2

Contents?: true

Size: 856 Bytes

Versions: 8

Compression:

Stored size: 856 Bytes

Contents

module Thredded
  class PostDecorator < SimpleDelegator
    attr_reader :post

    def initialize(post)
      super
      @post = post
    end

    def user_name
      if user
        user.to_s
      else
        'Anonymous'
      end
    end

    def original
      post
    end

    def created_at_timeago
      if created_at.nil?
        <<-eohtml.strip_heredoc.html_safe
          <abbr>
            a little while ago
          </abbr>
        eohtml
      else
        <<-eohtml.strip_heredoc.html_safe
          <abbr class="timeago" title="#{created_at_utc}">
            #{created_at_str}
          </abbr>
        eohtml
      end
    end

    def gravatar_url
      super.gsub /http:/, ''
    end

    private

    def created_at_str
      created_at.getutc.to_s
    end

    def created_at_utc
      created_at.getutc.iso8601
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
thredded-0.0.10 app/decorators/thredded/post_decorator.rb
thredded-0.0.9 app/decorators/thredded/post_decorator.rb
thredded-0.0.8 app/decorators/thredded/post_decorator.rb
thredded-0.0.7 app/decorators/thredded/post_decorator.rb
thredded-0.0.6 app/decorators/thredded/post_decorator.rb
thredded-0.0.5 app/decorators/thredded/post_decorator.rb
thredded-0.0.4 app/decorators/thredded/post_decorator.rb
thredded-0.0.3 app/decorators/thredded/post_decorator.rb