Sha256: 3095188623c7c143e06032d6dbfa478d46f3982fe5d38121c3c6e8d135615b09
Contents?: true
Size: 772 Bytes
Versions: 7
Compression:
Stored size: 772 Bytes
Contents
# frozen_string_literal: true module Acfs::Resource::Attributes # @api public # # List attribute type. Use it in your model as an attribute type: # # @example # class User < Acfs::Resource # attribute :name, :list # end # class List < Base # @api public # # Cast given object to a list. # # @param [Object] value Object to cast. # @return [Fixnum] Casted object as list. # @raise [TypeError] If object cannot be casted to a list. # def cast_value(value) return [] if value.blank? if value.is_a?(::Array) value elsif value.respond_to?(:to_ary) value.to_ary elsif value.respond_to?(:to_a) value.to_a else Array(value) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems