Class: Superfluid::Environment
- Inherits:
-
Struct
- Object
- Struct
- Superfluid::Environment
- Defined in:
- lib/superfluid/environment.rb
Overview
The default Liquid environment.
Instance Attribute Summary collapse
-
#default_resource_limits ⇒ Object
Returns the value of attribute default_resource_limits.
-
#error_mode ⇒ Object
Returns the value of attribute error_mode.
-
#exception_renderer ⇒ Object
Returns the value of attribute exception_renderer.
-
#file_system ⇒ Object
Returns the value of attribute file_system.
-
#filter_registry ⇒ Object
Returns the value of attribute filter_registry.
-
#tags ⇒ Object
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
- #create_filter_registry(_context = nil, filters = Core::EMPTY_ARRAY, namespace: Liquid::StandardFilters) ⇒ Object (also: #create_strainer)
- #filter_names ⇒ Object (also: #filter_method_names)
- #find_tag(name) ⇒ Object (also: #tag_for_name)
- #freeze ⇒ Object
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
- #register_filter(namespace) ⇒ Object
- #register_filters ⇒ Object
- #register_tag(name, klass) ⇒ Object
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/superfluid/environment.rb', line 27 def initialize(**) super self[:default_resource_limits] ||= Core::EMPTY_HASH self[:error_mode] ||= :strict self[:exception_renderer] ||= Core::Identity self[:file_system] ||= Systems::Memory.new self[:filter_registry] ||= Registries::Filter.for mode: error_mode self[:tags] ||= Liquid::Tags::STANDARD_TAGS.dup @filters_cache = {} end |
Instance Attribute Details
#default_resource_limits ⇒ Object
Returns the value of attribute default_resource_limits
7 8 9 |
# File 'lib/superfluid/environment.rb', line 7 def default_resource_limits @default_resource_limits end |
#error_mode ⇒ Object
Returns the value of attribute error_mode
7 8 9 |
# File 'lib/superfluid/environment.rb', line 7 def error_mode @error_mode end |
#exception_renderer ⇒ Object
Returns the value of attribute exception_renderer
7 8 9 |
# File 'lib/superfluid/environment.rb', line 7 def exception_renderer @exception_renderer end |
#file_system ⇒ Object
Returns the value of attribute file_system
7 8 9 |
# File 'lib/superfluid/environment.rb', line 7 def file_system @file_system end |
#filter_registry ⇒ Object
Returns the value of attribute filter_registry
7 8 9 |
# File 'lib/superfluid/environment.rb', line 7 def filter_registry @filter_registry end |
#tags ⇒ Object
Returns the value of attribute tags
7 8 9 |
# File 'lib/superfluid/environment.rb', line 7 def @tags end |
Class Method Details
.default ⇒ Object
23 24 25 |
# File 'lib/superfluid/environment.rb', line 23 def self.default @default ||= new end |
.for {|instance| ... } ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/superfluid/environment.rb', line 15 def self.for(**) instance = new(**) yield instance if block_given? instance.freeze end |
Instance Method Details
#create_filter_registry(_context = nil, filters = Core::EMPTY_ARRAY, namespace: Liquid::StandardFilters) ⇒ Object Also known as: create_strainer
40 41 42 43 44 45 46 |
# File 'lib/superfluid/environment.rb', line 40 def create_filter_registry _context = nil, filters = Core::EMPTY_ARRAY, namespace: Liquid::StandardFilters return filter_registry if filters.empty? filter_registry.add(namespace, *filters) end |
#filter_names ⇒ Object Also known as: filter_method_names
50 |
# File 'lib/superfluid/environment.rb', line 50 def filter_names = filter_registry.names |
#find_tag(name) ⇒ Object Also known as: tag_for_name
71 |
# File 'lib/superfluid/environment.rb', line 71 def find_tag(name) = [name.to_s] |
#freeze ⇒ Object
75 76 77 78 |
# File 'lib/superfluid/environment.rb', line 75 def freeze .freeze super end |
#register_filter(namespace) ⇒ Object
54 55 56 57 58 |
# File 'lib/superfluid/environment.rb', line 54 def register_filter(namespace, **) filters_cache.clear filter_registry.add(namespace, **) self end |
#register_filters ⇒ Object
60 61 62 63 64 |
# File 'lib/superfluid/environment.rb', line 60 def register_filters(*, **) filters_cache.clear filter_registry.add(*, **) self end |
#register_tag(name, klass) ⇒ Object
66 67 68 69 |
# File 'lib/superfluid/environment.rb', line 66 def register_tag name, klass [name.to_s] = klass self end |