Class: Navigatrix::ItemBuilder

Inherits:
Builder
  • Object
show all
Defined in:
lib/navigatrix/builder.rb

Instance Attribute Summary

Attributes inherited from Builder

#klass

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Builder

build, #define_method, #initialize

Constructor Details

This class inherits a constructor from Navigatrix::Builder

Class Method Details

.klassObject



33
34
35
# File 'lib/navigatrix/builder.rb', line 33

def self.klass
  Navigatrix::Rendering::Strategies::Item
end

Instance Method Details

#children_options(&block) ⇒ Object



55
56
57
58
59
# File 'lib/navigatrix/builder.rb', line 55

def children_options(&block)
  define_method(:children_options) do
    instance_exec(super(), &block)
  end
end

#html_attributes(&block) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/navigatrix/builder.rb', line 61

def html_attributes(&block)
  define_method(:html_attributes) do
    instance_exec(&block).inject(super()) do |acc, (key, val)|
      acc.merge_attribute(key, val)
    end
  end
end

#linked(&block) ⇒ Object



43
44
45
46
47
# File 'lib/navigatrix/builder.rb', line 43

def linked(&block)
  define_method(:linked_content) do
    instance_exec(name, path, &block)
  end
end

#unlinked(&block) ⇒ Object



49
50
51
52
53
# File 'lib/navigatrix/builder.rb', line 49

def unlinked(&block)
  define_method(:unlinked_content) do
    instance_exec(name, path, &block)
  end
end

#wrapper(&block) ⇒ Object



37
38
39
40
41
# File 'lib/navigatrix/builder.rb', line 37

def wrapper(&block)
  define_method(:render) do
    instance_exec(name_or_link, render_children, html_attributes, &block) if render?
  end
end