Class: Voom::Presenters::DSL::Components::Menu

Inherits:
Base
  • Object
show all
Defined in:
lib/voom/presenters/dsl/components/menu.rb

Defined Under Namespace

Modules: BaseMenuItem Classes: Divider, Item, Label

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #css_class, #draggable, #drop_zone, #id, #tag, #type

Instance Method Summary collapse

Methods inherited from Base

#expand!

Methods included from Pluggable

#include_plugins, #plugin, #plugin_module

Methods included from Voom::Presenters::DSL::Components::Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

#initialize(title = nil, **attribs_, &block) ⇒ Menu

Returns a new instance of Menu.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/voom/presenters/dsl/components/menu.rb', line 8

def initialize(title=nil, **attribs_, &block)
  super(type: :menu, **attribs_, &block)
  @title = title
  @items = []
  @position = attribs.delete(:position){:left}
  @placement = attribs.delete(:placement){:default}
  @color = attribs.delete(:color)
  @open = attributes.delete(:open) {false}
  @hoisted = attributes.delete(:hoisted) {true}
  expand!
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def color
  @color
end

#hoistedObject

Returns the value of attribute hoisted.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def hoisted
  @hoisted
end

#itemsObject

Returns the value of attribute items.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def items
  @items
end

#openObject

Returns the value of attribute open.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def open
  @open
end

#placementObject

Returns the value of attribute placement.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def placement
  @placement
end

#positionObject

Returns the value of attribute position.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def position
  @position
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/voom/presenters/dsl/components/menu.rb', line 6

def title
  @title
end

Instance Method Details

#divider(**attribs, &block) ⇒ Object



26
27
28
29
# File 'lib/voom/presenters/dsl/components/menu.rb', line 26

def divider(**attribs, &block)
  @items << Divider.new(parent: self,
                        **attribs, &block)
end

#item(first_text = nil, text: nil, **attribs, &block) ⇒ Object



20
21
22
23
24
# File 'lib/voom/presenters/dsl/components/menu.rb', line 20

def item(first_text = nil, text: nil, **attribs, &block)
  the_text = first_text || text
  @items << Item.new(parent: self, text: the_text,
                     **attribs, &block)
end

#label(**attribs, &block) ⇒ Object



31
32
33
34
35
# File 'lib/voom/presenters/dsl/components/menu.rb', line 31

def label(**attribs, &block)
  return @label if locked?
  @label = Label.new(parent: self,
                     **attribs, &block)
end