class Apipie::Params::Descriptor::Base
Public Class Methods
find(argument, options, block)
click to toggle source
find the right descriptor for given options
# File lib/apipie/params/descriptor.rb, line 22 def self.find(argument, options, block) if argument.is_a? Descriptor::Base return argument end # in case param description (or something else quacking the # same) is passed if argument.respond_to?(:descriptor) && argument.descriptor.is_a?(Descriptor::Base) return argument.descriptor end @descriptor_classes.each do |descriptor_class| descriptor = descriptor_class.build(argument, options, block) return descriptor if descriptor end return nil end
inherited(subclass)
click to toggle source
# File lib/apipie/params/descriptor.rb, line 16 def self.inherited(subclass) @descriptor_classes ||= [] @descriptor_classes.insert 0, subclass end
new(options)
click to toggle source
# File lib/apipie/params/descriptor.rb, line 8 def initialize(options) if options.is_a? ::Hash @options = options else @options = {} end end
Public Instance Methods
description()
click to toggle source
to be used in the error description and json representation
# File lib/apipie/params/descriptor.rb, line 43 def description "" end
invalid_param_error(param_description, error_value, errors = [])
click to toggle source
# File lib/apipie/params/descriptor.rb, line 47 def invalid_param_error(param_description, error_value, errors = []) Params::Errors::Invalid.new(param_description, error_value, description) end
to_json()
click to toggle source
# File lib/apipie/params/descriptor.rb, line 51 def to_json self.json_schema end