Sha256: d010598a333bd620771ae904d0b40b15de9b39915a6f20e00db129ab69dc7e32
Contents?: true
Size: 661 Bytes
Versions: 5
Compression:
Stored size: 661 Bytes
Contents
module Acfs::Resource::Attributes # @api public # # Dict attribute type. Use it in your model as an attribute type: # # @example # class User # include Acfs::Model # attribute :opts, :dict # end # class Dict < Base # @api public # # Cast given object to a dict/hash. # # @param [Object] obj Object to cast. # @return [Hash] Casted object as hash. # @raise [TypeError] If object cannot be casted to a hash. # def cast_type(obj) return obj if obj.is_a? Hash return obj.to_h if obj.respond_to? :to_h raise TypeError.new "Cannot cast #{obj.inspect} to hash." end end end
Version data entries
5 entries across 5 versions & 1 rubygems