Class: Super::ViewChain

Inherits:
Object
  • Object
show all
Defined in:
lib/super/view_chain.rb

Instance Method Summary collapse

Constructor Details

#initialize(chain) ⇒ ViewChain

Returns a new instance of ViewChain.



5
6
7
# File 'lib/super/view_chain.rb', line 5

def initialize(chain)
  @data = ReorderableHash.new(chain)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/super/view_chain.rb', line 25

def empty?
  chain.empty?
end

#handle_super_render(template, local_assigns, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/super/view_chain.rb', line 29

def handle_super_render(template, local_assigns, &block)
  name, current = shift
  current = template.super_resolve_renderable(current)

  if !current
    Rails.logger.warn do
      "Super::ViewChain encountered a nil view: #{name.inspect}."
    end
  end

  if empty?
    template.super_render(current)
  else
    template.super_render(current) do
      template.concat(template.super_render(self))
    end
  end
end

#insert(*args, **kwargs) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/super/view_chain.rb', line 9

def insert(*args, **kwargs)
  if instance_variable_defined?(:@chain)
    raise Error::ViewChain::ChainAlreadyStarted
  end

  @data.insert(*args, **kwargs)
end

#shiftObject



21
22
23
# File 'lib/super/view_chain.rb', line 21

def shift
  chain.shift
end

#to_partial_pathObject



17
18
19
# File 'lib/super/view_chain.rb', line 17

def to_partial_path
  "view_chain"
end