Module: Rack::Cache::Config
- Included in:
- Context
- Defined in:
- lib/rack/cache/config.rb
Overview
Provides cache configuration methods. This module is included in the cache context object.
Instance Method Summary collapse
-
#configure(&block) ⇒ Object
Evaluate a block of configuration code within the scope of receiver.
-
#import(file) ⇒ Object
Import the configuration file specified.
Instance Method Details
#configure(&block) ⇒ Object
Evaluate a block of configuration code within the scope of receiver.
9 10 11 |
# File 'lib/rack/cache/config.rb', line 9 def configure(&block) instance_eval(&block) if block_given? end |
#import(file) ⇒ Object
Import the configuration file specified. This has the same basic semantics as Ruby’s built-in require statement but always evaluates the source file within the scope of the receiver. The file may exist anywhere on the $LOAD_PATH.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rack/cache/config.rb', line 17 def import(file) return false if imported_features.include?(file) path = add_file_extension(file, 'rb') if path = locate_file_on_load_path(path) source = File.read(path) imported_features.add(file) instance_eval source, path, 1 true else raise LoadError, 'no such file to load -- %s' % [file] end end |