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
- #fragment_digest ⇒ Object
- #fragments ⇒ Object
- #handle(commands, 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.
10 11 12 13 14 15 16 17 18 |
# File 'lib/props_template/extension_manager.rb', line 10 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.
8 9 10 |
# File 'lib/props_template/extension_manager.rb', line 8 def base @base end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
8 9 10 |
# File 'lib/props_template/extension_manager.rb', line 8 def builder @builder end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/props_template/extension_manager.rb', line 8 def context @context end |
Instance Method Details
#deferred ⇒ Object
33 34 35 |
# File 'lib/props_template/extension_manager.rb', line 33 def deferred @deferment.deferred end |
#fragment_digest ⇒ Object
37 38 39 |
# File 'lib/props_template/extension_manager.rb', line 37 def fragment_digest @fragment.name end |
#fragments ⇒ Object
41 42 43 |
# File 'lib/props_template/extension_manager.rb', line 41 def fragments @fragment.fragments end |
#handle(commands, options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/props_template/extension_manager.rb', line 49 def handle(commands, ) return yield if !has_extensions() if [:defer] placeholder = @deferment.handle() commands.push([:push_value, placeholder]) @fragment.handle() else handle_cache() do base.set_block_content! do if [:partial] current_digest = @fragment.name @fragment.handle() @partialer.handle() @fragment.name = current_digest else yield end end end end end |
#has_extensions(options) ⇒ Object
45 46 47 |
# File 'lib/props_template/extension_manager.rb', line 45 def has_extensions() [:defer] || [:cache] || [:partial] end |
#refine_all_item_options(all_options) ⇒ Object
27 28 29 30 31 |
# File 'lib/props_template/extension_manager.rb', line 27 def () = @partialer.find_and_add_template() = @cache.multi_fetch_and_add_results() end |
#refine_options(options, item = nil) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/props_template/extension_manager.rb', line 20 def (, item = nil) = @partialer.(, item) = @deferment.(, item) = Cache.(, item) end |