Sha256: 15da8c864260c490e29bb3c96c6ed76306af53f6aa1aed4ce99eadde89f02ddc

Contents?: true

Size: 507 Bytes

Versions: 1

Compression:

Stored size: 507 Bytes

Contents

# frozen_string_literal: true

module ViewComponentScopedCss
  #
  # Manage whether CSS has been Render
  #
  class CurrentContext < ActiveSupport::CurrentAttributes
    attribute :called

    def self.render_if_need(view_component_class)
      self.called ||= {}
      if called[view_component_class.name]
        nil
      else
        called[view_component_class.name] = true
        ViewComponentScopedCss::Tag.new(view_component_class).call
      end
    end

    resets { self.called = {} }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
view_component_scoped_css-0.2.0 lib/view_component_scoped_css/current_context.rb