validate arguments type
# File lib/apipie/validator.rb, line 79 def self.build(param_description, argument, options, block) if argument.is_a?(Class) && (argument != Hash || block.nil?) self.new(param_description, argument) end end
# File lib/apipie/validator.rb, line 69 def initialize(param_description, argument) super(param_description) @type = argument end
# File lib/apipie/validator.rb, line 89 def description "Parameter has to be #{@type}." end
# File lib/apipie/validator.rb, line 85 def error "Parameter #{param_name} expecting to be #{@type.name}, got: #{@error_value.class.name}" end
# File lib/apipie/validator.rb, line 93 def expected_type if @type.ancestors.include? Hash 'hash' elsif @type.ancestors.include? Numeric 'numeric' else 'string' end end
# File lib/apipie/validator.rb, line 74 def validate(value) return false if value.nil? value.is_a? @type end