Class: Diva::Type::AtomicType
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from MetaType
Instance Method Summary collapse
-
#initialize(name, recommended_class, *rest, &cast) ⇒ AtomicType
constructor
A new instance of AtomicType.
- #recommendation_point(value) ⇒ Object
- #schema ⇒ Object
- #uri ⇒ Object
Methods inherited from MetaType
#cast, #dump_for_json, #inspect, #to_s
Constructor Details
#initialize(name, recommended_class, *rest, &cast) ⇒ AtomicType
Returns a new instance of AtomicType.
81 82 83 84 |
# File 'lib/diva/type.rb', line 81 def initialize(name, recommended_class, *rest, &cast) super(name, *rest, &cast) @recommended_classes = Array(recommended_class) end |
Instance Method Details
#recommendation_point(value) ⇒ Object
86 87 88 89 |
# File 'lib/diva/type.rb', line 86 def recommendation_point(value) _, point = @recommended_classes.map.with_index { |k, i| [k, i] }.find { |k, _| value.is_a?(k) } point end |
#schema ⇒ Object
91 92 93 |
# File 'lib/diva/type.rb', line 91 def schema @schema ||= { type: uri }.freeze end |