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.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #deferred ⇒ Object
- #fragments ⇒ Object
- #handle(options) ⇒ Object
- #has_extensions(options) ⇒ Object
-
#initialize(base, defered = [], fragments = []) ⇒ ExtensionManager
constructor
A new instance of ExtensionManager.
- #refine_all_item_options(all_options) ⇒ Object
- #refine_options(options, item = nil) ⇒ Object
Constructor Details
#initialize(base, defered = [], fragments = []) ⇒ ExtensionManager
Returns a new instance of ExtensionManager.
5 6 7 8 9 10 11 12 13 |
# File 'lib/props_template/extension_manager.rb', line 5 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 |
#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 |
Instance Method Details
#deferred ⇒ Object
28 29 30 |
# File 'lib/props_template/extension_manager.rb', line 28 def deferred @deferment.deferred end |
#fragments ⇒ Object
32 33 34 |
# File 'lib/props_template/extension_manager.rb', line 32 def fragments @fragment.fragments end |
#handle(options) ⇒ Object
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 |
# File 'lib/props_template/extension_manager.rb', line 40 def handle() return yield if !has_extensions() if [:defer] placeholder = @deferment.handle() base.stream.push_value(placeholder) @fragment.handle() else handle_cache() do base.set_block_content! do if [:partial] @fragment.handle() @partialer.handle() else yield end if [:key] id, val = [:key] base.set!(id, val) end end end end end |
#has_extensions(options) ⇒ Object
36 37 38 |
# File 'lib/props_template/extension_manager.rb', line 36 def has_extensions() [:defer] || [:cache] || [:partial] || [:key] end |
#refine_all_item_options(all_options) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/props_template/extension_manager.rb', line 21 def () return if .empty? = @partialer.find_and_add_template() @cache.multi_fetch_and_add_results() end |
#refine_options(options, item = nil) ⇒ Object
15 16 17 18 19 |
# File 'lib/props_template/extension_manager.rb', line 15 def (, item = nil) = @partialer.(, item) = @deferment.(, item) Cache.(, item) end |