Class: Rack::PageSpeed::Config
- Inherits:
-
Object
- Object
- Rack::PageSpeed::Config
- Defined in:
- lib/rack/pagespeed/config.rb
Defined Under Namespace
Classes: NoSuchFilter, NoSuchStorageMechanism
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#public ⇒ Object
readonly
Returns the value of attribute public.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Config
constructor
A new instance of Config.
- #method_missing(filter, *args) ⇒ Object
- #store(type = nil, *args) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 |
# File 'lib/rack/pagespeed/config.rb', line 8 def initialize = {}, &block @filters, @options, @public = [], , [:public] raise ArgumentError, ":public needs to be a directory" unless File.directory? @public.to_s filters_to_methods instance_eval &block if block_given? sort_filters end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(filter, *args) ⇒ Object
32 33 34 |
# File 'lib/rack/pagespeed/config.rb', line 32 def method_missing filter, *args raise NoSuchFilter, "No such filter \"#{filter}\". Available filters: #{(Rack::PageSpeed::Filter.available_filters).join(', ')}" end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
6 7 8 |
# File 'lib/rack/pagespeed/config.rb', line 6 def filters @filters end |
#public ⇒ Object (readonly)
Returns the value of attribute public.
6 7 8 |
# File 'lib/rack/pagespeed/config.rb', line 6 def public @public end |
Instance Method Details
#store(type = nil, *args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/pagespeed/config.rb', line 18 def store type = nil, *args return @store unless type case type when {} @store = {} # simple in-memory store when Symbol @store = load_storage type, *args when Hash store *type.to_a.first else raise NoSuchStorageMechanism, "No such storage mechanism: #{type}" end end |