def coerce(value, object, type)
      return value if value.nil?

      if type.is_a?(Enumerable)
        objects = value.map { |e| coerce(e, object, type.first) }
        if type.respond_to?(:find_by)
          return type.class.new({}).populate(objects)
        else
          return type.class.new(objects)
        end
      elsif type.ancestors.include? Flickr::Object
        return type.new(value, object.access_token)
      else
        COERCIONS.fetch(type).each do |coercion|
          begin
            return coercion.call(value)
          rescue
          end
        end
      end

      value
    end
def coerce(value, object, type)
      return value if value.nil?

      if type.is_a?(Enumerable)
        objects = value.map { |e| coerce(e, object, type.first) }
        if type.respond_to?(:find_by)
          return type.class.new({}).populate(objects)
        else
          return type.class.new(objects)
        end
      elsif type.ancestors.include? Flickr::Object
        return type.new(value, object.access_token)
      else
        COERCIONS.fetch(type).each do |coercion|
          begin
            return coercion.call(value)
          rescue
          end
        end
      end

      value
    end
It coerces the found attribute value into a given type. For example, "boolean"
 type is represented in JSON as an integer (1/0), so values of this type need to
 be coerced the appropriate true/false values.