module Shaf::UriHelperMethods

Public Class Methods

add_path_helpers(clazz, methods) click to toggle source
# File lib/shaf/extensions/resource_uris.rb, line 51
def add_path_helpers(clazz, methods)
  path_helpers[clazz].concat Array(methods)
end
eval_method(str) click to toggle source
# File lib/shaf/extensions/resource_uris.rb, line 47
def eval_method(str)
  class_eval str
end
path_helpers() click to toggle source
# File lib/shaf/extensions/resource_uris.rb, line 60
def path_helpers
  @path_helpers ||= Hash.new { |hash, key| hash[key] = [] }
end
path_helpers_for(clazz = nil) click to toggle source
# File lib/shaf/extensions/resource_uris.rb, line 55
def path_helpers_for(clazz = nil)
  return path_helpers unless clazz
  path_helpers[clazz]
end
register(name, &block) click to toggle source
# File lib/shaf/extensions/resource_uris.rb, line 43
def register(name, &block)
  define_method(name, &block)
end
remove_all() click to toggle source

For cleaning up after tests

# File lib/shaf/extensions/resource_uris.rb, line 65
def remove_all
  helpers = instance_methods - [:path_helpers]
  remove_method(*helpers)
  @path_helpers = Hash.new { |hash, key| hash[key] = [] }
end

Public Instance Methods

path_helpers() click to toggle source
# File lib/shaf/extensions/resource_uris.rb, line 72
def path_helpers
  clazz = is_a?(Class) ? self : self.class
  UriHelperMethods.path_helpers_for clazz
end