0.0
No commit activity in last 3 years
No release in over 3 years
RequestGlobal provides global storage per request for Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
 Project Readme

RequestGlobal Gem Version Code Climate Build Status

RequestGlobal provides global storage per request for Rails. The core part of RequestGlobal is written in Ruby's C API.

Installation

Add this line to your Gemfile:

gem 'request_global'

And then execute:

$ bundle

Or install it yourself as:

$ gem install request_global

Usage

Each storage of request is a Hash.

# Setter methods
RequestGlobal.store(:foo, 1) #=> 1
RequestGlobal[:bar] = 2 #=> 2

# Getter methods
RequestGlobal.fetch(:bar) #=> 2
RequestGlobal[:foo] #=> 1

# Delete
RequestGlobal.delete(:bar)

# Clear storage of current request
RequestGlobal.clear!

No Rails?

RequestGlobal provides Railtie which configures Rack middleware. However, if you're not using Rails, use middleware yourself like following:

use RequestGlobal::Middleware

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cryeo/request_global.

License

The gem is available as open source under the terms of the MIT License.