Class: SimpleEnum::Accessors::WhinyAccessor

Inherits:
Accessor
  • Object
show all
Defined in:
lib/simple_enum/accessors/whiny_accessor.rb

Instance Attribute Summary

Attributes inherited from Accessor

#enum, #name, #source

Instance Method Summary collapse

Methods inherited from Accessor

#changed?, #initialize, #prefix, #read, #scope, #selected?, #to_s, #was

Constructor Details

This class inherits a constructor from SimpleEnum::Accessors::Accessor

Instance Method Details

#write(object, key) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
# File 'lib/simple_enum/accessors/whiny_accessor.rb', line 6

def write(object, key)
  raise ArgumentError, "#{key} is not a valid enum value for #{enum}" if key && !enum.include?(key)
  super
end