lib/apia/definitions/type.rb
# Cast the given value into an response that can be sent to the
# consumer.
#
# @param value [Object, nil]
# @param request [Apia::Request, nil]
# @return [Object, nil]
Cast the given value into an response that can be sent to the
consumer.
Cast the given value into an response that can be sent to the consumer .
def cast(value, request: nil, path: [])
        return nil if value.nil?
        if scalar? || enum?
          klass.cast(value)
        elsif object?
          object = klass.new(value)
          return :skip unless object.include?(request)
          object.hash(request: request, path: path)
        elsif polymorph?
          option = klass.option_for_value(value)
          option.cast(value, request: request, path: path)
        end
      end
def cast ( value , request : nil , path : [ ] ) return nil if value . nil? if scalar? || enum? klass . cast ( value ) elsif object? object = klass . new ( value ) return :skip unless object . include? ( request ) object . hash ( request : request , path : path ) elsif polymorph? option = klass . option_for_value ( value ) option . cast ( value , request : request , path : path ) end end
Cast the given value into an response that can be sent to the
consumer.
Cast the given value into an response that can be sent to the consumer .
# If this is a scalar or an enum, we're going to just return the # value that they return. There's nothing complicated about them # and they return scalars. # If this field returns an object, we'll go ahead and generate # the hash for the object at this point. # If this item shouldn't be included. we'll return :skip which # will instruct the field set not to include it at all. # Otherwise, we'll return the hash # If the type is a polymorph and this value
None
Object, nil
value
<not_specific>
request
<not_specific>
path
<not_specific>
<not_specific>
None