Sha256: 8ddccc5042df84ef9daddc4f8f88e506437b94475afa5dcef0c6b8d97de96647

Contents?: true

Size: 403 Bytes

Versions: 18

Compression:

Stored size: 403 Bytes

Contents

module Superstore
  module Types
    class ArrayType < BaseType
      def encode(array)
        raise ArgumentError.new("#{array.inspect} is not an Array") unless array.kind_of?(Array)
        array.to_a.to_json
      end

      def decode(str)
        return nil if str.blank?

        ActiveSupport::JSON.decode(str)
      end

      def typecast(value)
        value.to_a
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
superstore-1.2.0 lib/superstore/types/array_type.rb
superstore-1.1.4 lib/superstore/types/array_type.rb
superstore-1.1.3 lib/superstore/types/array_type.rb
superstore-1.1.2 lib/superstore/types/array_type.rb
superstore-1.1.1 lib/superstore/types/array_type.rb
superstore-1.1.0 lib/superstore/types/array_type.rb
superstore-1.0.12 lib/superstore/types/array_type.rb
superstore-1.0.11 lib/superstore/types/array_type.rb
superstore-1.0.10 lib/superstore/types/array_type.rb
superstore-1.0.9 lib/superstore/types/array_type.rb
superstore-1.0.8 lib/superstore/types/array_type.rb
superstore-1.0.7 lib/superstore/types/array_type.rb
superstore-1.0.6 lib/superstore/types/array_type.rb
superstore-1.0.5 lib/superstore/types/array_type.rb
superstore-1.0.4 lib/superstore/types/array_type.rb
superstore-1.0.3 lib/superstore/types/array_type.rb
superstore-1.0.2 lib/superstore/types/array_type.rb
superstore-1.0.0 lib/superstore/types/array_type.rb