class StrongJSON::Type::Array
Attributes
type[R]
@dynamic type
Public Class Methods
new(type)
click to toggle source
# File lib/strong_json/type.rb, line 160 def initialize(type) @type = type end
Public Instance Methods
==(other)
click to toggle source
# File lib/strong_json/type.rb, line 178 def ==(other) if other.is_a?(Array) 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 164 def coerce(value, path: ErrorPath.root(self)) if value.is_a?(::Array) value.map.with_index do |v, i| @type.coerce(v, path: path.dig(key: i, type: @type)) end else raise TypeError.new(path: path, value: value) end end
to_s()
click to toggle source
# File lib/strong_json/type.rb, line 174 def to_s self.alias&.to_s || "array(#{@type})" end