Sha256: 93e4e82ece9de07ff5006e87004635f61a577f48dfa18e74e37b2c00118f3699

Contents?: true

Size: 856 Bytes

Versions: 1

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.name
      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

1 entries across 1 versions & 1 rubygems

Version Path
thredded-0.0.1 app/decorators/thredded/post_decorator.rb