Sha256: b9a11f4d950516c4837176d329d9142806b916d68550da674e2c0b8eb68b7dfc

Contents?: true

Size: 704 Bytes

Versions: 17

Compression:

Stored size: 704 Bytes

Contents

module AmaLayout
  module DraperReplacement
    extend ActiveSupport::Concern

    included do
      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

17 entries across 17 versions & 1 rubygems

Version Path
ama_layout-10.2.0 lib/ama_layout/draper_replacement.rb
ama_layout-10.1.0 lib/ama_layout/draper_replacement.rb
ama_layout-10.0.1 lib/ama_layout/draper_replacement.rb
ama_layout-9.5.3 lib/ama_layout/draper_replacement.rb
ama_layout-9.5.2 lib/ama_layout/draper_replacement.rb
ama_layout-9.5.1 lib/ama_layout/draper_replacement.rb
ama_layout-9.5.0 lib/ama_layout/draper_replacement.rb
ama_layout-9.4.1 lib/ama_layout/draper_replacement.rb
ama_layout-9.4.0 lib/ama_layout/draper_replacement.rb
ama_layout-9.3.0 lib/ama_layout/draper_replacement.rb
ama_layout-9.2.0 lib/ama_layout/draper_replacement.rb
ama_layout-9.1.0 lib/ama_layout/draper_replacement.rb
ama_layout-9.0.0 lib/ama_layout/draper_replacement.rb
ama_layout-8.0.2 lib/ama_layout/draper_replacement.rb
ama_layout-8.0.1 lib/ama_layout/draper_replacement.rb
ama_layout-8.0.0 lib/ama_layout/draper_replacement.rb
ama_layout-7.0.2 lib/ama_layout/draper_replacement.rb