module Identification
Ruby on Rails 1.2.1
Last seen in v1.3.0Mix GlobalID::Identification into any model with a ‘#find(id)` class method. Support is automatically included in Active Record.
class Person include ActiveModel::Model include GlobalID::Identification attr_accessor :id def self.find(id) new id: id end def ==(other) id == other.try(:id) end end person_gid = Person.find(1).to_global_id # => #<GlobalID ... person_gid.uri # => #<URI ... person_gid.to_s # => "gid://app/Person/1" GlobalID::Locator.locate person_gid # => #<Person:0x007fae94bf6298 @id="1">