Sha256: 3f034cca9012abc1affa213fb2ccfd32d4d70a69ed7a08aed47860444eb669fe

Contents?: true

Size: 657 Bytes

Versions: 3

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

require 'active_support'

module LHS
  module OptionBlocks
    extend ActiveSupport::Concern

    class CurrentOptionBlock
      # Using ActiveSupports PerThreadRegistry to be able to support Active Support v4.
      # Will switch to thread_mattr_accessor (which comes with Activesupport) when we dropping support for Active Support v4.
      extend ActiveSupport::PerThreadRegistry
      attr_accessor :options
    end

    module ClassMethods
      def options(options, &block)
        CurrentOptionBlock.options = options
        block.call
      ensure
        CurrentOptionBlock.options = nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lhs-20.1.1 lib/lhs/concerns/option_blocks.rb
lhs-20.0.0 lib/lhs/concerns/option_blocks.rb
lhs-19.10.0 lib/lhs/concerns/option_blocks.rb