class StrongJSON::Type::Optional
Attributes
type[R]
@dynamic type
Public Class Methods
new(type)
click to toggle source
# File lib/strong_json/type.rb, line 95 def initialize(type) @type = type end
Public Instance Methods
==(other)
click to toggle source
# File lib/strong_json/type.rb, line 111 def ==(other) if other.is_a?(Optional) other.type == type end end
Also aliased as: eql?
coerce(value, path: ErrorPath.root(self))
click to toggle source
# File lib/strong_json/type.rb, line 99 def coerce(value, path: ErrorPath.root(self)) unless value == nil @type.coerce(value, path: path.expand(type: @type)) else nil end end
to_s()
click to toggle source
# File lib/strong_json/type.rb, line 107 def to_s self.alias&.to_s || "optional(#{@type})" end