Module: Shaf::UriHelperMethods
Class Method Summary collapse
- .add_path_helpers(clazz, methods) ⇒ Object
- .eval_method(str) ⇒ Object
- .path_helpers ⇒ Object
- .path_helpers_for(clazz = nil) ⇒ Object
- .register(name, &block) ⇒ Object
-
.remove_all ⇒ Object
For cleaning up after tests.
Instance Method Summary collapse
Class Method Details
.add_path_helpers(clazz, methods) ⇒ Object
51 52 53 |
# 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) ⇒ Object
47 48 49 |
# File 'lib/shaf/extensions/resource_uris.rb', line 47 def eval_method(str) class_eval str end |
.path_helpers ⇒ Object
60 61 62 |
# 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) ⇒ Object
55 56 57 58 |
# 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) ⇒ Object
43 44 45 |
# File 'lib/shaf/extensions/resource_uris.rb', line 43 def register(name, &block) define_method(name, &block) end |
.remove_all ⇒ Object
For cleaning up after tests
65 66 67 68 69 |
# 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 |
Instance Method Details
#path_helpers ⇒ Object
72 73 74 75 |
# 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 |