Module: Rack::Sprockets::Options::InstanceMethods
- Defined in:
- lib/rack/sprockets/options.rb
Instance Method Summary collapse
-
#option_name(key) ⇒ Object
Rack::Sprockets uses the Rack Environment to store option values.
-
#options(key = nil) ⇒ Object
The underlying options Hash.
-
#options=(hash = {}) ⇒ Object
Set multiple options at once.
-
#set(option, value = nil) ⇒ Object
Set an option.
Instance Method Details
#option_name(key) ⇒ Object
Rack::Sprockets uses the Rack Environment to store option values. All options are stored in the Rack Environment as “<RACK_ENV_PREFIX>.<option>”, where <option> is the option name.
69 70 71 |
# File 'lib/rack/sprockets/options.rb', line 69 def option_name(key) self.class.option_name(key) end |
#options(key = nil) ⇒ Object
The underlying options Hash. During initialization (or outside of a request), this is a default values Hash. During a request, this is the Rack environment Hash. The default values Hash is merged in underneath the Rack environment before each request is processed.
> if a key is passed, the option value for the key is returned
78 79 80 81 82 83 84 |
# File 'lib/rack/sprockets/options.rb', line 78 def (key=nil) if key (@env || @default_options)[option_name(key)] else @env || @default_options end end |
#options=(hash = {}) ⇒ Object
Set multiple options at once.
87 88 89 |
# File 'lib/rack/sprockets/options.rb', line 87 def (hash={}) hash.each { |key,value| write_option(key, value) } end |
#set(option, value = nil) ⇒ Object
Set an option. When option
is a Symbol, it is set in the Rack Environment as “rack-cache.option”. When option
is a String, it exactly as specified. The option
argument may also be a Hash in which case each key/value pair is merged into the environment as if the #set method were called on each.
96 97 98 99 100 101 102 |
# File 'lib/rack/sprockets/options.rb', line 96 def set(option, value=nil) if value.nil? self. = option.to_hash else write_option option, value end end |