Class: Voom::Presenters::DSL::Components::Select

Inherits:
Input show all
Defined in:
lib/voom/presenters/dsl/components/select.rb

Defined Under Namespace

Classes: Option

Instance Attribute Summary collapse

Attributes inherited from Input

#name

Attributes inherited from EventBase

#event_parent_id

Attributes included from Mixins::Event

#events

Attributes inherited from Base

#attributes, #context, #id, #type

Instance Method Summary collapse

Methods included from Mixins::Tooltips

#tooltip

Methods included from Mixins::Event

#event

Methods inherited from Base

#expand!

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ Select

Returns a new instance of Select.



11
12
13
14
15
16
17
# File 'lib/voom/presenters/dsl/components/select.rb', line 11

def initialize(**attribs_, &block)
  super(type: :select, **attribs_, &block)
  @required = attribs.delete(:required)
  @full_width = attribs.delete(:full_width) || true
  @options = []
  expand!
end

Instance Attribute Details

#full_widthObject (readonly)

Returns the value of attribute full_width.



9
10
11
# File 'lib/voom/presenters/dsl/components/select.rb', line 9

def full_width
  @full_width
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/voom/presenters/dsl/components/select.rb', line 9

def options
  @options
end

#requiredObject (readonly)

Returns the value of attribute required.



9
10
11
# File 'lib/voom/presenters/dsl/components/select.rb', line 9

def required
  @required
end

Instance Method Details

#icon(icon = nil, **attribs, &block) ⇒ Object



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

def icon(icon=nil, **attribs, &block)
  return @icon if locked?
  @icon = Components::Icon.new(parent: self, icon: icon,
                               context: context,
                               **attribs, &block)
end

#label(text = nil) ⇒ Object



19
20
21
22
# File 'lib/voom/presenters/dsl/components/select.rb', line 19

def label(text=nil)
  return @label if locked?
  @label = text
end

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



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

def option(**attribs, &block)
  @options << Option.new(parent: self,
                         context: context,
                         **attribs, &block)
end