Sha256: 2ad7ef783ec74c5f3c7ea9195615dba8f775c4645684e9490c0fa8a1af018823
Contents?: true
Size: 825 Bytes
Versions: 18
Compression:
Stored size: 825 Bytes
Contents
class Module # Bulk converts the security level of methods in this Module from one level to another. def convert_security_of_methods(old_level = :public, new_level = :protected) eval("#{old_level}_instance_methods").each{ |meth| self.send(new_level, meth) } self 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) def include_safely_into(*args) [args].flatten.each do |a| if a.is_a?(String) || a.is_a?(Symbol) a = a.to_s.constantize end a.send(:include, self.convert_security_of_methods) end end end
Version data entries
18 entries across 18 versions & 1 rubygems