Sha256: 58d471e2386053b5c01e2fb73e1936a4bfeee2522e6e6aa235e2bd886bce0c06

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

module DuckPuncher
  module Registration
    def register(target, *mods)
      options = mods.last.is_a?(Hash) ? mods.pop : {}
      target = DuckPuncher.lookup_constant target
      Ducks.list[target] = [] unless Ducks.list.key?(target)
      Array(mods).each do |mod|
        duck = Duck.new target, mod, options
        Ducks.list[target] << duck
        decorators[target] = new_decorator(duck, *Ducks[target])
      end
      nil
    end

    def deregister(*classes)
      classes.each &Ducks.list.method(:delete)
      classes.each &decorators.method(:delete)
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duck_puncher-4.0.0 lib/duck_puncher/registration.rb