Class: CastingAttrAccessor::Parser::Enum

Inherits:
Symbol
  • Object
show all
Defined in:
lib/casting_attr_accessor/parser/enum.rb

Instance Attribute Summary

Attributes inherited from Base

#attribute, #model, #options

Instance Method Summary collapse

Methods inherited from Base

#default_value, #initialize, #readers, #storage_var, #writers

Constructor Details

This class inherits a constructor from CastingAttrAccessor::Parser::Base

Instance Method Details

#parse(value) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/casting_attr_accessor/parser/enum.rb', line 5

def parse(value)
  if options.key?(:from)
    super(value) if options[:from].include?(value_sym)
  else
    raise ArgumentError.new 'Flags attribute has to specify a set of possible values'
  end
end