Sha256: def8cccd5159fa9544ac9d8b96f6315cc576aef236b6d9d0330db4e8c8faeabf
Contents?: true
Size: 485 Bytes
Versions: 4
Compression:
Stored size: 485 Bytes
Contents
require 'virtus' require_relative 'stream' require_relative 'coercions' module Vedeu class InvalidStream < StandardError; end class StreamCollection < Virtus::Attribute include Coercions def coerce(values) return [] if empty?(values) if multiple?(values) values.map { |v| Stream.new(v) } elsif single?(values) [Stream.new(values)] elsif values.is_a?(String) [Stream.new({ text: values })] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems