class Rasti::Types::Array

Attributes

type[R]

Public Class Methods

[](type) click to toggle source
# File lib/rasti/types/array.rb, line 9
def self.[](type)
  new type
end
new(type) click to toggle source
# File lib/rasti/types/array.rb, line 20
def initialize(type)
  @type = type
end

Public Instance Methods

inspect()
Alias for: to_s
to_s() click to toggle source
# File lib/rasti/types/array.rb, line 13
def to_s
  "#{self.class}[#{type}]"
end
Also aliased as: inspect

Private Instance Methods

transform(value) click to toggle source
# File lib/rasti/types/array.rb, line 28
def transform(value)
  MultiCaster.cast!(self, value) do |multi_caster|
    value.map.with_index do |e,i|
      multi_caster.cast type: type,
                        value: e,
                        error_key: i+1
    end
  end
end
valid?(value) click to toggle source
# File lib/rasti/types/array.rb, line 24
def valid?(value)
  value.is_a? ::Array
end