Class: Ramenu::Menus::Builder
- Inherits:
-
Object
- Object
- Ramenu::Menus::Builder
- Defined in:
- lib/ramenu/menus.rb
Overview
The Builder class represents the abstract class for any custom Builder.
To create a custom Builder, just extend this class and implement the following abstract methods:
-
#render
: Renders and returns the collection of navigation elements
Direct Known Subclasses
Instance Method Summary collapse
-
#flag_for(element, option = :flag) ⇒ Object
get flag associated to element.
-
#initialize(context, elements, options = {}) ⇒ Builder
constructor
Initializes a new Builder with
context
,element
andoptions
. -
#render ⇒ String
abstract
Renders Elements and returns the Breadcrumb navigation for the view.
Constructor Details
#initialize(context, elements, options = {}) ⇒ Builder
Initializes a new Builder with context
, element
and options
.
21 22 23 24 25 |
# File 'lib/ramenu/menus.rb', line 21 def initialize(context, elements, = {}) @context = context @elements = elements @options = end |
Instance Method Details
#flag_for(element, option = :flag) ⇒ Object
get flag associated to element
37 38 39 40 41 42 43 44 |
# File 'lib/ramenu/menus.rb', line 37 def flag_for(element, option = :flag) flag = nil flag_selector = element.[option] unless flag_selector.nil? flag = @options[:flags][flag_selector] if @options[:flags].include?(flag_selector) end return flag end |
#render ⇒ String
This method is abstract.
You must implement this method in your custom Builder.
Renders Elements and returns the Breadcrumb navigation for the view.
32 33 34 |
# File 'lib/ramenu/menus.rb', line 32 def render raise NotImplementedError end |