Sha256: b94301a8c738436a4cbde6b4687fc08c7e0b6cd05e2b9a7b9ff2a763d8a6ca91

Contents?: true

Size: 837 Bytes

Versions: 7

Compression:

Stored size: 837 Bytes

Contents

# frozen_string_literal: true

require_relative '../../app/helpers/ama_layout_partial_helper'

module AmaLayout
  module DraperReplacement
    extend ActiveSupport::Concern

    included do
      include AmaLayoutPartialHelper

      attr_accessor :object, :controller

      def h(view_data = {})
        AmaLayoutView.new(view_data: view_data)
      end

      def initialize(args = {})
        self.object = args
      end

      def method_missing(method, *args, &block)
        return super unless delegatable?(method)

        (object || DraperReplacement).send(method, *args, &block)
      end

      def delegatable?(method)
        object.respond_to?(method) || DraperReplacement.respond_to?(method)
      end

      def self.decorate_collection(objects = {})
        objects.map { |o| self.new(o) }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ama_layout-11.5.1 lib/ama_layout/draper_replacement.rb
ama_layout-11.5.0 lib/ama_layout/draper_replacement.rb
ama_layout-11.4.0 lib/ama_layout/draper_replacement.rb
ama_layout-11.3.1 lib/ama_layout/draper_replacement.rb
ama_layout-11.3.0 lib/ama_layout/draper_replacement.rb
ama_layout-11.2.0 lib/ama_layout/draper_replacement.rb
ama_layout-11.1.0 lib/ama_layout/draper_replacement.rb