Module: Card::Format::Nesting::Main

Included in:
Card::Format::Nesting
Defined in:
lib/card/format/nesting/main.rb

Overview

Handle the main nest

Instance Method Summary collapse

Instance Method Details

#already_mained?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/card/format/nesting/main.rb', line 30

def already_mained?
  return true if @main || @already_main

  @already_main = true
  false
end

#main!Object



37
38
39
# File 'lib/card/format/nesting/main.rb', line 37

def main!
  @main = true
end

#main_nest(opts) ⇒ Object



10
11
12
13
14
# File 'lib/card/format/nesting/main.rb', line 10

def main_nest opts
  wrap_main do
    main.rendered || main_nest_render(opts)
  end
end

#main_nest?(nest_name) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/card/format/nesting/main.rb', line 26

def main_nest? nest_name
  nest_name == "_main" # && !root.already_mained?
end

#main_nest_optionsObject

view=edit&items=closed



42
43
44
# File 'lib/card/format/nesting/main.rb', line 42

def main_nest_options
  inherit(:main_opts) || {}
end

#main_nest_render(opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/card/format/nesting/main.rb', line 16

def main_nest_render opts={}
  with_nest_mode :normal do
    if block_given?
      block.call
    else
      nest root.card, opts.merge(main_view: true, main: true)
    end
  end
end

#wrap_mainObject



6
7
8
# File 'lib/card/format/nesting/main.rb', line 6

def wrap_main
  yield # no wrapping in base format
end