Method: Jsapi::Meta::Existence.from
- Defined in:
- lib/jsapi/meta/existence.rb
.from(value) ⇒ Object
Transforms value to an instance of this class.
Raises an ArgumentError if value could not be transformed.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jsapi/meta/existence.rb', line 36 def self.from(value) return value if value.is_a?(Existence) case value when :present, true PRESENT when :allow_empty ALLOW_EMPTY when :allow_nil, :allow_null ALLOW_NIL when :allow_omitted, false, nil ALLOW_OMITTED else raise ArgumentError, "invalid existence: #{value}" end end |