Skip to content

Commit

Permalink
Make Person comparable
Browse files Browse the repository at this point in the history
  • Loading branch information
dhower-qc committed Dec 17, 2024
1 parent e22ae2b commit 32c9053
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/arch_obj_models/obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ def text

# Personal information about a contributor
class Person
include Comparable

# @return [String] Person's name
def name = @data["name"]

Expand All @@ -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.:
Expand Down

0 comments on commit 32c9053

Please sign in to comment.