Sha256: 8a5d33a62513824a1995529afa4e3e40be75cad0f892316ade826afd1f209f1c
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require_dependency 'thredded/urls_helper' module Thredded # A view model for PostCommon. class PostView delegate :filtered_content, :avatar_url, :created_at, :user, :to_model, :pending_moderation?, :approved?, :blocked?, to: :@post # @param post [Thredded::PostCommon] # @param policy [#update? #destroy?] def initialize(post, policy) @post = post @policy = policy end def can_update? @can_update ||= @policy.update? end def can_destroy? @can_destroy ||= @policy.destroy? end def edit_path Thredded::UrlsHelper.edit_post_path(@post) end def destroy_path Thredded::UrlsHelper.delete_post_path(@post) end def cache_key [ I18n.locale, @post, @post.user, [ !@post.private_topic_post? && @post.pending_moderation? && !Thredded.content_visible_while_pending_moderation, can_update?, can_destroy? ].map { |p| p ? '+' : '-' } * '' ] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thredded-0.5.1 | app/view_models/thredded/post_view.rb |
thredded-0.5.0 | app/view_models/thredded/post_view.rb |