Sha256: f3d28b35ef6e8bc68ee52e6ea624d2e6946626818d07fe9a72079c9a866d3700

Contents?: true

Size: 538 Bytes

Versions: 1

Compression:

Stored size: 538 Bytes

Contents

# frozen_string_literal: true

module ViewComponentScopedCss
  #
  # Hook before_render to view component to provide inline css
  #
  module Hook
    extend ActiveSupport::Concern
    included do
      include ActiveSupport::Callbacks
      define_callbacks :render
    end

    def before_render
      run_callbacks :render do
        ViewComponentScopedCss::CurrentContext.add(self.class)
      end
    end

    class_methods do
      def before_render(&block)
        set_callback(:render, :before, &block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
view_component_scoped_css-0.1.2 lib/view_component_scoped_css/hook.rb