Class: Daedal::Attributes::TypeValue

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

Constant Summary collapse

ALLOWED_QUERY_VALUE_CLASSES =
[String, Symbol]

Instance Method Summary collapse

Instance Method Details

#coerce(q) ⇒ Object



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

def coerce(q)
  if !required? and q.nil?
    return q
  elsif ALLOWED_QUERY_VALUE_CLASSES.include? q.class
    return q
  else
    raise Virtus::CoercionError.new(q, self.class)
  end
end