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

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

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 Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

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

Returns a new instance of Option.



47
48
49
50
51
52
53
54
# File 'lib/voom/presenters/dsl/components/select.rb', line 47

def initialize(**attribs_, &block)
  super(type: :select_option, **attribs_, &block)
  @value = self.value(attribs.delete(:value))
  @text = self.text(attribs.delete(:text))
  @selected =  attribs.delete(:selected)
  @disabled =  attribs.delete(:disabled)
  expand!
end

Instance Attribute Details

#disabledObject (readonly)

Returns the value of attribute disabled.



45
46
47
# File 'lib/voom/presenters/dsl/components/select.rb', line 45

def disabled
  @disabled
end

#selectedObject (readonly)

Returns the value of attribute selected.



45
46
47
# File 'lib/voom/presenters/dsl/components/select.rb', line 45

def selected
  @selected
end

Instance Method Details

#text(text = nil) ⇒ Object



61
62
63
64
# File 'lib/voom/presenters/dsl/components/select.rb', line 61

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

#value(value = nil) ⇒ Object



56
57
58
59
# File 'lib/voom/presenters/dsl/components/select.rb', line 56

def value(value=nil)
  return @value if locked?
  @value = value
end