| Class | Module |
| In: |
lib/mack-facets/extensions/module.rb
|
| Parent: | Object |
Bulk converts the security level of methods in this Module from one level to another.
# File lib/mack-facets/extensions/module.rb, line 4 4: def convert_security_of_methods(old_level = :public, new_level = :protected) 5: eval("#{old_level}_instance_methods").each{ |meth| self.send(new_level, meth) } 6: self 7: end
Includes this module into a Class, and changes all public methods to protected.
Examples:
module MyCoolUtils
def some_meth
"hi"
end
self.include_safely_into(FooController)
end
or:
MyCoolUtils.include_safely_into(FooController, SomeOtherClass)
# File lib/mack-facets/extensions/module.rb, line 20
20: def include_safely_into(*args)
21: [args].flatten.each do |a|
22: if a.is_a?(String) || a.is_a?(Symbol)
23: a = a.to_s.constantize
24: end
25: a.send(:include, self.convert_security_of_methods)
26: end
27: end