Class: Jschematic::Attributes::UniqueItems
- Inherits:
-
Object
- Object
- Jschematic::Attributes::UniqueItems
- Includes:
- Element
- Defined in:
- lib/jschematic/attributes/unique_items.rb
Instance Attribute Summary
Attributes included from Element
Instance Method Summary collapse
- #accepts?(instance) ⇒ Boolean
-
#initialize(value = false) ⇒ UniqueItems
constructor
A new instance of UniqueItems.
Methods included from Element
#required?, #schema_for, #title, #to_s
Constructor Details
#initialize(value = false) ⇒ UniqueItems
Returns a new instance of UniqueItems.
8 9 10 |
# File 'lib/jschematic/attributes/unique_items.rb', line 8 def initialize(value=false) @value = value end |
Instance Method Details
#accepts?(instance) ⇒ Boolean
12 13 14 15 |
# File 'lib/jschematic/attributes/unique_items.rb', line 12 def accepts?(instance) require true unless Array === instance (instance == instance.uniq) || fail_validation!("all items to be unique", instance) end |