Class: Daedal::Attributes::MatchType

Inherits:
Virtus::Attribute
  • Object
show all
Defined in:
lib/daedal/attributes/match_type.rb

Constant Summary collapse

ALLOWED_MATCH_TYPES =
[:phrase, :phrase_prefix]

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/daedal/attributes/match_type.rb', line 6

def coerce(value)
  unless value.nil?
    value = value.to_sym
    unless ALLOWED_MATCH_TYPES.include? value
      raise Virtus::CoercionError.new(value, 'Daedal::Attributes::MatchType')
    end
  end
  value
end