Sha256: a23db8eb2c2d50bf695810144469d22dd07f999137a95d1dbcb5a28bd5639a8a
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
class Module # Returns an anonymous module with the specified methods # of the receiving module renamed. # # NOTE: These is likely to be usurped by traits.rb. # # CREDIT: Trans def clone_renaming( pairs ) mod = self.dup pairs.each_pair{ |to_sym, from_sym| mod.class_eval{ alias_method( to_sym, from_sym ) undef_method( from_sym ) } } return mod end # Returns an anonymous module with the specified methods # of the receiving module removed. # # NOTE: These is likely to be usurped by traits.rb. # # CREDIT: Trans def clone_removing( *meths ) mod = self.dup methods_to_remove = meths methods_to_remove.each{ |m| mod.class_eval{ remove_method m } } return mod end # Returns an anonymous module with only the specified methods # of the receiving module intact. # # NOTE: These is likely to be usurped by traits.rb. # # CREDIT: Trans def clone_using( *methods ) methods.collect!{ |m| m.to_s } methods_to_remove = instance_methods - methods mod = self.dup mod.class_eval{ methods_to_remove.each{ |m| undef_method m } } return mod end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-2.3.0 | lib/core/facets/module/clone.rb |
facets-2.2.0 | lib/core/facets/module/clone.rb |
facets-2.2.1 | lib/core/facets/module/clone.rb |