Class: Props::ExtensionManager

Inherits:
Object
  • Object
show all
Defined in:
lib/props_template/extension_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#baseObject (readonly)

Returns the value of attribute base.



8
9
10
# File 'lib/props_template/extension_manager.rb', line 8

def base
  @base
end

#builderObject (readonly)

Returns the value of attribute builder.



8
9
10
# File 'lib/props_template/extension_manager.rb', line 8

def builder
  @builder
end

#contextObject (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

#deferredObject



33
34
35
# File 'lib/props_template/extension_manager.rb', line 33

def deferred
  @deferment.deferred
end

#fragment_digestObject



37
38
39
# File 'lib/props_template/extension_manager.rb', line 37

def fragment_digest
  @fragment.name
end

#fragmentsObject



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, options)
  return yield if !has_extensions(options)

  if options[:defer]
    placeholder = @deferment.handle(options)
    commands.push([:push_value, placeholder])
    @fragment.handle(options)
  else
    handle_cache(options) do
      base.set_block_content! do
        if options[:partial]
          current_digest = @fragment.name
          @fragment.handle(options)
          @partialer.handle(options)
          @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(options)
  options[:defer] || options[:cache] || options[:partial]
end

#refine_all_item_options(all_options) ⇒ Object



27
28
29
30
31
# File 'lib/props_template/extension_manager.rb', line 27

def refine_all_item_options(all_options)
  all_options = @partialer.find_and_add_template(all_options)
  all_options = @cache.multi_fetch_and_add_results(all_options)
  all_options
end

#refine_options(options, item = nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/props_template/extension_manager.rb', line 20

def refine_options(options, item = nil)
  options = @partialer.refine_options(options, item)
  options = @deferment.refine_options(options, item)
  options = Cache.refine_options(options, item)
  options
end