Skip to content
RequestStore API similar to ActiveSupport::PerThreadRegistry.
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
request_store_registry.gemspec

README.md

RequestStoreRegistry

If you need a global state for a request in Rails, request_store by Steve Klabnik is a great solution.

This gem provides API for RequestStore, that is similar to ActiveSupport::PerThreadRegistry API.

Usage

You define a class that extends this module:

  module ActiveRecord
    class RuntimeRegistry
      extend RequestStoreRegistry
      attr_accessor :connection_handler
    end
  end

and invoke the declared instance accessors as class methods. So

  ActiveRecord::RuntimeRegistry.connection_handler = connection_handler

sets a connection handler local to the current thread, and

  ActiveRecord::RuntimeRegistry.connection_handler

returns a connection handler local to the current thread.

Contributing

  1. Fork it ( https://github.com/[my-github-username]/request_store_registry/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
You can’t perform that action at this time.