Project

dangerless

0.0
No commit activity in last 3 years
No release in over 3 years
Programmatically generate instance methods that return a cloned copy of the object.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 12.0
~> 4.2
~> 0.49
~> 3.2
 Project Readme

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!]