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, #context, #id, #type

Instance Method Summary collapse

Methods inherited from Base

#expand!

Methods included from Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

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

Returns a new instance of Option.



40
41
42
43
44
45
46
47
# File 'lib/voom/presenters/dsl/components/select.rb', line 40

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.



38
39
40
# File 'lib/voom/presenters/dsl/components/select.rb', line 38

def disabled
  @disabled
end

#selectedObject (readonly)

Returns the value of attribute selected.



38
39
40
# File 'lib/voom/presenters/dsl/components/select.rb', line 38

def selected
  @selected
end

Instance Method Details

#text(text = nil) ⇒ Object



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

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

#value(value = nil) ⇒ Object



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

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