Class: Props::ExtensionManager
- Inherits:
-
Object
- Object
- Props::ExtensionManager
- Defined in:
- lib/props_template/extension_manager.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#partialer ⇒ Object
readonly
Returns the value of attribute partialer.
Instance Method Summary collapse
- #deferred ⇒ Object
- #disable_deferments ⇒ Object
- #fragments ⇒ Object
- #handle(options, item_context = nil) ⇒ Object
- #has_extensions(options) ⇒ Object
-
#initialize(base, defered = [], fragments = []) ⇒ ExtensionManager
constructor
A new instance of ExtensionManager.
Constructor Details
#initialize(base, defered = [], fragments = []) ⇒ ExtensionManager
Returns a new instance of ExtensionManager.
8 9 10 11 12 13 14 15 16 |
# File 'lib/props_template/extension_manager.rb', line 8 def initialize(base, defered = [], fragments = []) @base = base @context = base.context @builder = base.builder @fragment = Fragment.new(base, fragments) @deferment = Deferment.new(base, defered) @partialer = Partialer.new(base, context, builder) @cache = Cache.new(@context) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
3 4 5 |
# File 'lib/props_template/extension_manager.rb', line 3 def base @base end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
3 4 5 |
# File 'lib/props_template/extension_manager.rb', line 3 def builder @builder end |
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
3 4 5 |
# File 'lib/props_template/extension_manager.rb', line 3 def cache @cache end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/props_template/extension_manager.rb', line 3 def context @context end |
#partialer ⇒ Object (readonly)
Returns the value of attribute partialer.
3 4 5 |
# File 'lib/props_template/extension_manager.rb', line 3 def partialer @partialer end |
Instance Method Details
#deferred ⇒ Object
22 23 24 |
# File 'lib/props_template/extension_manager.rb', line 22 def deferred @deferment.deferred end |
#disable_deferments ⇒ Object
18 19 20 |
# File 'lib/props_template/extension_manager.rb', line 18 def disable_deferments @deferment.disable! end |
#fragments ⇒ Object
26 27 28 |
# File 'lib/props_template/extension_manager.rb', line 26 def fragments @fragment.fragments end |
#handle(options, item_context = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/props_template/extension_manager.rb', line 34 def handle(, item_context = nil) return yield if !has_extensions() if (key = [:key]) && item_context val = if item_context.respond_to? key item_context.send(key) elsif item_context.is_a? Hash item_context[key] || item_context[key.to_sym] end end deferment_type = @deferment.extract_deferment_type(, item_context) if !@deferment.disabled if deferment_type placeholder = @deferment.handle(, deferment_type, key, val) base.stream.push_value(placeholder) @fragment.handle(, item_context) else handle_cache(, item_context) do base.set_content! do if [:partial] @fragment.handle(, item_context) @partialer.handle(, item_context) else yield end if key && val base.set!(key, val) end end end end end |
#has_extensions(options) ⇒ Object
30 31 32 |
# File 'lib/props_template/extension_manager.rb', line 30 def has_extensions() [:defer] || [:cache] || [:partial] || [:key] end |