Class: Liquid::Strainer
- Inherits:
-
Object
- Object
- Liquid::Strainer
- Defined in:
- lib/liquid/strainer.rb
Overview
Strainer is the parent class for the filters system. New filters are mixed into the strainer class which is then instanciated for each liquid template render run.
One of the strainer’s responsibilities is to keep malicious method calls out
Constant Summary collapse
- INTERNAL_METHOD =
:nodoc:
/^__/
- @@required_methods =
Set.new([:__id__, :__send__, :respond_to?, :extend, :methods, :class, :object_id])
- @@filters =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context) ⇒ Strainer
constructor
A new instance of Strainer.
- #respond_to?(method, include_private = false) ⇒ Boolean
Constructor Details
#initialize(context) ⇒ Strainer
Returns a new instance of Strainer.
24 25 26 |
# File 'lib/liquid/strainer.rb', line 24 def initialize(context) @context = context end |
Class Method Details
.create(context) ⇒ Object
33 34 35 36 37 |
# File 'lib/liquid/strainer.rb', line 33 def self.create(context) strainer = Strainer.new(context) @@filters.each { |k,m| strainer.extend(m) } strainer end |
.global_filter(filter) ⇒ Object
28 29 30 31 |
# File 'lib/liquid/strainer.rb', line 28 def self.global_filter(filter) raise ArgumentError, "Passed filter is not a module" unless filter.is_a?(Module) @@filters[filter.name] = filter end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
39 40 41 42 43 44 |
# File 'lib/liquid/strainer.rb', line 39 def respond_to?(method, include_private = false) method_name = method.to_s return false if method_name =~ INTERNAL_METHOD return false if @@required_methods.include?(method_name) super end |