Sha256: b0f769d6b45f104d3d8025dc66a04c6c789a7670b92e924cd851a34c5542adcf

Contents?: true

Size: 915 Bytes

Versions: 26

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module Plutonium
  module UI
    module Component
      module Behaviour
        extend ActiveSupport::Concern
        include Methods
        include Kit

        if Rails.env.development?
          def around_template(&)
            comment { "open:#{self.class.name}" }
            super
            comment { "close:#{self.class.name}" }
          end
        end

        protected

        def phlexi_render(arg, &)
          return unless arg
          raise ArgumentError, "phlexi_render requires a default render block" unless block_given?

          # Handle Phlex components or Rails Renderables
          if arg.class < Phlex::SGML || arg.respond_to?(:render_in)
            render arg
          # Handle procs
          elsif arg.respond_to?(:to_proc)
            instance_exec(&arg)
          else
            yield
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
plutonium-0.15.2 lib/plutonium/ui/component/behaviour.rb
plutonium-0.15.1 lib/plutonium/ui/component/behaviour.rb
plutonium-0.15.0 lib/plutonium/ui/component/behaviour.rb
plutonium-0.15.0.pre.rc3 lib/plutonium/ui/component/behaviour.rb
plutonium-0.15.0.pre.rc2 lib/plutonium/ui/component/behaviour.rb
plutonium-0.15.0.pre.rc1 lib/plutonium/ui/component/behaviour.rb