Skip to content

Instantly share code, notes, and snippets.

@diago
Created October 24, 2011 20:21
Show Gist options
  • Save diago/1310048 to your computer and use it in GitHub Desktop.
Save diago/1310048 to your computer and use it in GitHub Desktop.
# Instance Methods for ControlPanel::Resources
module ResourceInstanceMethods
def initialize( slug_params = {} )
@slug_params = slug_params
end
def slug
self.class::RESOURCE.split( '/' ).map do |p|
if p.start_with?( ':' )
@slug_params.has_key?( p.to_sym ) ? @slug_params.fetch( p.to_sym ) : ''
else
p
end
end.join('/')
end
end # ResourceInstanceMethods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment