diff --git a/lib/arch_obj_models/obj.rb b/lib/arch_obj_models/obj.rb index 388a3b947..567893b5d 100644 --- a/lib/arch_obj_models/obj.rb +++ b/lib/arch_obj_models/obj.rb @@ -350,6 +350,8 @@ def text # Personal information about a contributor class Person + include Comparable + # @return [String] Person's name def name = @data["name"] @@ -364,6 +366,12 @@ def company = @data["company"] def initialize(data) @data = data end + + def <=>(other) + raise ArgumentError, "Person is only comparable to Person (not #{other.class.name})" unless other.is_a?(Person) + + name <=> other.name + end end # represents a JSON Schema compoisition, e.g.: