You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Garner in a project (really, a couple projects) where we don't ever need to bind to ActiveRecord or Mongoid objects. Instead, we want to cache certain data (the roles to which a user belongs) and bind it to the OAuth token they present.
Right now, I'm doing this by monkey-patching the AccessToken class in an initializer:
Garner.configuredo |config|
# Other configuration options...config.binding_key_strategy=Garner::Strategies::Binding::Key::CacheKeyendmoduleFridgeclassAccessTokenincludeGarner::Cache::Bindingdefcache_keyidendendend
Then I can do stuff like:
garner.bind(token) { roles.map(&:href) }
What do we think is the appropriate way to "Garner-ify" non-ORM objects? Is re-opening the class the right way to do this? Right now, it's necessary to, at a minimum include Garner::Cache::Binding in any class whose instances will be used as bindings. Is there a better way?
The text was updated successfully, but these errors were encountered:
Reopening is probably fine, except I think I would like to write something like Fridge::AccessToken.extend Garner::Cache::Binding::GenericBindingById. Maybe there's a way to delegate this, too?
I'm using Garner in a project (really, a couple projects) where we don't ever need to bind to ActiveRecord or Mongoid objects. Instead, we want to cache certain data (the roles to which a user belongs) and bind it to the OAuth token they present.
Right now, I'm doing this by monkey-patching the
AccessToken
class in an initializer:Then I can do stuff like:
What do we think is the appropriate way to "Garner-ify" non-ORM objects? Is re-opening the class the right way to do this? Right now, it's necessary to, at a minimum
include Garner::Cache::Binding
in any class whose instances will be used as bindings. Is there a better way?The text was updated successfully, but these errors were encountered: