Class: Formidable::Elements::Option

Inherits:
Element show all
Defined in:
lib/formidable/elements.rb

Constant Summary

Constants included from Coercions

Coercions::IncompatibleInterface, Coercions::MissingCoercion

Constants included from Rendering

Rendering::RendererNotAssigned

Instance Attribute Summary

Attributes inherited from BasicElement

#attributes, #content, #name, #tag

Attributes included from Rendering

#renderer

Instance Method Summary collapse

Methods included from Coercions

#coerce, #coerce!, #coercions, coercions, included

Methods included from Validations

#errors, register_validation, #valid?, #validate, #validations

Methods included from Rendering

included, #render

Constructor Details

#initialize(value, attributes = Hash.new, &block) ⇒ Option

Returns a new instance of Option.



320
321
322
323
# File 'lib/formidable/elements.rb', line 320

def initialize(value, attributes = Hash.new, &block)
  self.content = block.call
  super(:option, nil, attributes.merge!(value: value))
end

Instance Method Details

#cleaned_dataObject



329
330
331
# File 'lib/formidable/elements.rb', line 329

def cleaned_data
  @cleaned_data ||= self.raw_data
end

#raw_dataObject



325
326
327
# File 'lib/formidable/elements.rb', line 325

def raw_data
  @raw_data ||= self.attributes[:value]
end