Sha256: b5745cb270cd0cb0ed07503000c010a67da4dba924a022227f492fadb2a71ce7

Contents?: true

Size: 538 Bytes

Versions: 123

Compression:

Stored size: 538 Bytes

Contents

# The original Module class.
#
class Module # :nodoc:all

  def each_delegate *methods
    options = methods.pop
    unless options.is_a?(Hash) && to = options[:to]
      raise ArgumentError, "Multi delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :something, :to => :an_array_reader)."
    end
    methods.each do |method|
      module_eval("def #{method}(*args, &block)\n#{to}.each{ |t| t.__send__(#{method.inspect}, *args, &block) }\nend\n", "(__DELEGATION__)", 1)
    end
  end

end

Version data entries

123 entries across 123 versions & 1 rubygems

Version Path
picky-2.5.0 lib/picky/internals/extensions/module.rb
picky-2.4.3 lib/picky/internals/extensions/module.rb
picky-2.4.2 lib/picky/internals/extensions/module.rb
picky-2.4.1 lib/picky/internals/extensions/module.rb
picky-2.4.0 lib/picky/internals/extensions/module.rb
picky-2.3.0 lib/picky/internals/extensions/module.rb
picky-2.2.1 lib/picky/internals/extensions/module.rb
picky-2.2.0 lib/picky/internals/extensions/module.rb
picky-2.1.2 lib/picky/internals/extensions/module.rb
picky-2.1.1 lib/picky/internals/extensions/module.rb
picky-2.1.0 lib/picky/internals/extensions/module.rb
picky-2.0.0 lib/picky/internals/extensions/module.rb
picky-2.0.0.pre3 lib/picky/internals/extensions/module.rb
picky-2.0.0.pre2 lib/picky/internals/extensions/module.rb
picky-2.0.0.pre1 lib/picky/internals/extensions/module.rb
picky-1.5.4 lib/picky/internals/extensions/module.rb
picky-1.5.3 lib/picky/internals/extensions/module.rb
picky-1.5.2 lib/picky/internals/extensions/module.rb
picky-1.5.1 lib/picky/internals/extensions/module.rb
picky-1.5.0 lib/picky/internals/extensions/module.rb