Sha256: 14c6cc382c89875b43c0ca23f834b9d93a1caf7a37530e19c421f8b607591a82

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require "talkie/comments_renderer"

module Talkie
  module RendererHelper
    extend ActiveSupport::Concern

    DELEGATED_METHODS_TO_COMMENTS_RENDERER = %i[commentable
                                                root_comments
                                                nested_enabled?
                                                display_user_handler?
                                                display_user_avatar?
                                                deletable?].freeze

    HELPER_METHODS = %i[talkie_on
                        nested_enabled?
                        display_user_handler?
                        display_user_avatar?
                        deletable?
                        root_comments
                        commentable].freeze

    included do
      delegate *DELEGATED_METHODS_TO_COMMENTS_RENDERER, to: :comments_renderer
      helper_method *HELPER_METHODS
    end

    protected

    def talkie_on(*args)
      options = args.extract_options!
      commentable = args[0]

      @comments_renderer ||= Talkie::CommentsRenderer.new(view_context, commentable, options)

      @comments_renderer.render
    end

    def comments_renderer
      @comments_renderer
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
talkie-0.4.0 lib/talkie/renderer_helper.rb
talkie-0.3.5 lib/talkie/renderer_helper.rb
talkie-0.3.4 lib/talkie/renderer_helper.rb
talkie-0.3.3 lib/talkie/renderer_helper.rb
talkie-0.3.2 lib/talkie/renderer_helper.rb
talkie-0.3.1 lib/talkie/renderer_helper.rb
talkie-0.3.0 lib/talkie/renderer_helper.rb
talkie-0.2.0 lib/talkie/renderer_helper.rb
talkie-0.1.1 lib/talkie/renderer_helper.rb