Class: Rack::PageSpeed::Filters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/pagespeed/filters/base.rb

Direct Known Subclasses

MinifyJavaScripts

Constant Summary collapse

@@subclasses =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/rack/pagespeed/filters/base.rb', line 8

def initialize options = {}
  @options = options
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



5
6
7
# File 'lib/rack/pagespeed/filters/base.rb', line 5

def document
  @document
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/rack/pagespeed/filters/base.rb', line 5

def options
  @options
end

Class Method Details

.available_filtersObject



17
18
19
# File 'lib/rack/pagespeed/filters/base.rb', line 17

def available_filters
  @@subclasses
end

.inherited(klass) ⇒ Object



13
14
15
# File 'lib/rack/pagespeed/filters/base.rb', line 13

def inherited klass
  @@subclasses << klass
end

.name(_name = nil) ⇒ Object



29
30
31
# File 'lib/rack/pagespeed/filters/base.rb', line 29

def name _name = nil
  _name ? @name = _name : @name ||= underscore(to_s)
end

.priority(_number = nil) ⇒ Object



33
34
35
# File 'lib/rack/pagespeed/filters/base.rb', line 33

def priority _number = nil
  _number ? @priority = _number.to_i : @priority
end

.requires_storeObject



21
22
23
24
25
26
27
# File 'lib/rack/pagespeed/filters/base.rb', line 21

def requires_store
  instance_eval do
    def new options = {}
      options[:store] ? super(options) : raise("#{name} requires :store to be specified.")
    end
  end
end