Class: KafoWizards::Entries::SelectorEntry

Inherits:
StringEntry show all
Defined in:
lib/kafo_wizards/entries/selector.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractEntry

#default_value, #description, #label, #name, #parent, #post_hook, #pre_hook, #validators, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractEntry

#call_post_hook, #call_pre_hook, descendants, #display_type, inherited, #required?, #update

Constructor Details

#initialize(name, options = {}) ⇒ SelectorEntry

Returns a new instance of SelectorEntry.



6
7
8
9
# File 'lib/kafo_wizards/entries/selector.rb', line 6

def initialize(name, options={})
  super(name, options)
  @options = options.fetch(:options, {})
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/kafo_wizards/entries/selector.rb', line 4

def options
  @options
end

Class Method Details

.entry_typeObject



16
17
18
# File 'lib/kafo_wizards/entries/selector.rb', line 16

def self.entry_type
  :selector
end

Instance Method Details

#validate(value) ⇒ Object



11
12
13
14
# File 'lib/kafo_wizards/entries/selector.rb', line 11

def validate(value)
  raise KafoWizards::ValidationError.new("#{value} is not a valid option") unless options.include?(value)
  value
end