Sha256: e5cfe24d6212fcb1ae7c1e8649cd9d389fecaeed172e0d49a90f8ee3469e4263
Contents?: true
Size: 787 Bytes
Versions: 6
Compression:
Stored size: 787 Bytes
Contents
module DropboxApi::Metadata class Field def initialize(type, options = []) @type = type @options = options end def cast(object) if object.nil? raise ArgumentError unless @options.include? :optional nil else force_cast object end end def force_cast(object) if @type == String object.to_s elsif @type == Time Time.parse(object) elsif @type == Integer object.to_i elsif @type == Symbol object[".tag"].to_sym elsif @type == :boolean object.to_s == "true" elsif @type.ancestors.include? DropboxApi::Metadata::Base @type.new(object) else raise NotImplementedError, "Can't cast `#{@type}`" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems