Skip to content

karagenit/dangerless

Repository files navigation

Dangerless

Travis CI Code Climate Gem Version Gem

Automatically Add Cloning (Safe) Variants of Bang (Dangerous) Methods (e.g. .method!)

Installation

From RubyGems:

$ gem install dangerless

Usage

Simply including the Dangerless module in your class will automatically generate the methods.

require 'dangerless'

def MyClass
  def modify!(args)
    ...
  end

  include Dangerless
end

MyClass.new.instance_methods #=> [:modify!, :modify]

NOTE: The call to include Dangerless must come after the definitions of any methods you want to be copied.

Of course, if you have some methods which you don't want "safe" duplicates of, you can simply define them after the call to include Dangerless:

require 'dangerless'

def MyClass
  include Dangerless

  def modify!(args)
    ...
  end
end

MyClass.new.instance_methods #=> [:modify!]

About

Automatically add Ruby method! Variants that Clone

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages