Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow apps to hook in their own locator #7

Closed
jeremy opened this issue Aug 16, 2014 · 2 comments
Closed

Allow apps to hook in their own locator #7

jeremy opened this issue Aug 16, 2014 · 2 comments
Milestone

Comments

@jeremy
Copy link
Member

jeremy commented Aug 16, 2014

When multiple apps collaborate and reference each others' Global IDs, they'll use different means to locate the URI references.

For example, locate an Active Resource class:

GlobalID::Locator.use :foo do |gid|
  FooRemote.const_get(gid.model_name).find(gid.model_id)
end

GlobalID::Locator.locate 'gid://foo/Account/1234'
# => FooRemote::Account id=1234

Or locate the referenced model in a search index:

GlobalID::Locator.use :bar, BarLocator.new

class BarLocator
  def locate(gid)
    @search_client.search name: gid.model_name, id: gid.model_id
  end
end

GlobalID::Locator.locate 'gid://bar/Account/1234'
# => BarResult name=Account id=1234
@jeremy jeremy added this to the 1.0 milestone Aug 16, 2014
@jeremy
Copy link
Member Author

jeremy commented Aug 21, 2014

Implemented by @kaspth ❤️

@jeremy jeremy closed this as completed Aug 21, 2014
@kaspth
Copy link
Contributor

kaspth commented Aug 21, 2014

Nice! Thanks, @jeremy ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants