Sha256: 566690ee71154ba03638cb7582554a6d7d0b1e517acf9f3dfa0c95706b04d47a

Contents?: true

Size: 702 Bytes

Versions: 11

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

require 'active_support'
require 'active_support/per_thread_registry'

module DHS
  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

11 entries across 11 versions & 1 rubygems

Version Path
dhs-1.5.0 lib/dhs/concerns/option_blocks.rb
dhs-1.4.2 lib/dhs/concerns/option_blocks.rb
dhs-1.4.1 lib/dhs/concerns/option_blocks.rb
dhs-1.4.0 lib/dhs/concerns/option_blocks.rb
dhs-1.3.0 lib/dhs/concerns/option_blocks.rb
dhs-1.2.0 lib/dhs/concerns/option_blocks.rb
dhs-1.1.0 lib/dhs/concerns/option_blocks.rb
dhs-1.0.3 lib/dhs/concerns/option_blocks.rb
dhs-1.0.2 lib/dhs/concerns/option_blocks.rb
dhs-1.0.1 lib/dhs/concerns/option_blocks.rb
dhs-1.0.0 lib/dhs/concerns/option_blocks.rb