Sha256: dce903560dd435e0480c6482800bede2cc8195329cb742804b1ca231f00d99cd

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

module Coprl
  module Presenters
    module Rails
      module Concerns
        module CoprlPartial
          extend ActiveSupport::Concern

          included do
            before_action :set_view_path
          end
          
          module ClassMethods
            @plugins = []
            def presenter_plugin(*plugins)
              @plugins += Array(plugins)
            end

            def plugins
              @plugins
            end
          end

          def set_view_path
            paths = Coprl::Presenters::WebClient::PluginViewsPath.new(pom: nil, plugins: self.class.plugins).render
            paths.each do |path|
              prepend_view_path path
            end
          end

          def prepare_context(base_params = params)
            prepare_context = Coprl::Presenters::Settings.config.presenters.web_client.prepare_context.dup
            prepare_context.push(method(:scrub_context))
            context = base_params.dup.to_unsafe_hash
            prepare_context.reduce(context) do |params, context_proc|
              context = context_proc.call(params, session, request.env)
            end
            context
          end

          def scrub_context(params, _session, _env)
            %i(grid_nesting input_tag).each do |key|
              params.delete(key) {params.delete(key.to_s)}
            end
            params
          end

        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.12 lib/coprl/presenters/rails/concerns/coprl_partial.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/rails/concerns/coprl_partial.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/rails/concerns/coprl_partial.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/rails/concerns/coprl_partial.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/rails/concerns/coprl_partial.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/rails/concerns/coprl_partial.rb