Skip to content

scarfacedeb/request_store_registry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

RequestStore API similar to ActiveSupport::PerThreadRegistry.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages