lib/apipie/validator.rb in apipie-rails-0.5.1 vs lib/apipie/validator.rb in apipie-rails-0.5.2
- old
+ new
@@ -11,10 +11,20 @@
def initialize(param_description)
@param_description = param_description
end
+ def inspected_fields
+ [:param_description]
+ end
+
+ def inspect
+ string = "#<#{self.class.name}:#{self.object_id} "
+ fields = inspected_fields.map {|field| "#{field}: #{self.send(field)}"}
+ string << fields.join(", ") << ">"
+ end
+
def self.inherited(subclass)
@validators ||= []
@validators.insert 0, subclass
end
@@ -65,16 +75,25 @@
def expected_type
'string'
end
def merge_with(other_validator)
- raise NotImplementedError, "Dont know how to merge #{self.inspect} with #{other_validator.inspect}"
+ return self if self == other_validator
+ raise NotImplementedError, "Don't know how to merge #{self.inspect} with #{other_validator.inspect}"
end
def params_ordered
nil
end
+ def ==(other)
+ return false unless self.class == other.class
+ if param_description == other.param_description
+ true
+ else
+ false
+ end
+ end
end
# validate arguments type
class TypeValidator < BaseValidator