Ask Your Question

How can I get the catalog object from within a provider class?

asked 2013-08-06 15:07:22 -0500

updated 2013-08-06 15:28:26 -0500

I am trying to search the catalog for a unique resource parameter and assign the title of the found resource as the parameter of another resource type instance during prefetch.

From a custom provider, I would like to be able to search the catalog for paramaters form a given resource. This is possible from within an instance of a provider because you can simply do resource.catalog which means you can do interesting things like the following.

resource.catalog.resources.find {|r| ... }

However, when working with the provider class where the resource object is not available, i.e. self.prefetch ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-08-06 18:20:07 -0500

Adrien Thebo gravatar image

This is a problematic question because of the architecture of providers. A provider instance has access to the resource object, because the provider instance models the resource. Otherwise phrased, there's a direct relationship between resources in a catalog and provider instances for those resources.

In contrast, a provider class doesn't have a direct relationship to the catalog. The provider class is mainly concerned with generating provider instances and generally doesn't need to directly interact with the catalog.

However, the provider class prefetch method is an exception to this. When a catalog is being applied, the prefetch method ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-08-06 15:07:22 -0500

Seen: 388 times

Last updated: Aug 06 '13