module Dangerless

Adds Safe Cloning Methods Automatically from Existing Dangerous ! Methods

Public Class Methods

included(parent) click to toggle source
# File lib/dangerless.rb, line 5
def self.included(parent)
  parent.instance_methods.each do |method|
    method = method.to_s
    next unless method.end_with? '!'
    define_method :"#{method.chomp('!')}" do |*params|
      copy = clone
      copy.send(method, *params)
      copy
    end
  end
end