Class: Jschematic::Attributes::Disallow
- Defined in:
- lib/jschematic/attributes/disallow.rb
Instance Attribute Summary
Attributes inherited from Type
Attributes included from Element
Instance Method Summary collapse
-
#accepts?(instance) ⇒ Boolean
disallow inverts the type attribute, so it succeeds if type fails.
Methods inherited from Type
Methods included from Element
#required?, #schema_for, #title, #to_s
Constructor Details
This class inherits a constructor from Jschematic::Attributes::Type
Instance Method Details
#accepts?(instance) ⇒ Boolean
disallow inverts the type attribute, so it succeeds if type fails
5 6 7 8 9 10 11 12 13 |
# File 'lib/jschematic/attributes/disallow.rb', line 5 def accepts?(instance) inverted = begin super false rescue ValidationError true end inverted || fail_validation!("instance not to be of type '#{type}'", instance) end |