Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2014 13:43
Show Gist options
  • Save anonymous/1143cbf35ca2ea766725 to your computer and use it in GitHub Desktop.
Save anonymous/1143cbf35ca2ea766725 to your computer and use it in GitHub Desktop.
namespace = options.fetch(:namespace, Object).name # V1 -> "V1
resource_namespace = resource.class.name.deconstantize # "Doorkeeper::AcccessToken" -> "Doorkeeper"
_module = "#{namespace}::#{resource_namespace}".constantize # V1::Doorkeeper
_module.const_get "#{resource.class.name.demodulize}Serializer" # const_get "AccessTokenSerializer"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment