Sha256: 932223d928f52288e81466a2122f62b60e9df64947229620cfe6c898a6bc7531

Contents?: true

Size: 378 Bytes

Versions: 26

Compression:

Stored size: 378 Bytes

Contents

class Module
  def foobara_delegate(*method_names, to:, allow_nil: false)
    method_names.each do |method_name|
      define_method method_name do |*args, **opts, &block|
        target = to.is_a?(::Symbol) || to.is_a?(::String) ? send(to) : to
        return nil if target.nil? && allow_nil

        target.send(method_name, *args, **opts, &block)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/delegate/src/extensions/module.rb
foobara-0.0.25 projects/delegate/src/extensions/module.rb
foobara-0.0.24 projects/delegate/src/extensions/module.rb
foobara-0.0.23 projects/delegate/src/extensions/module.rb
foobara-0.0.22 projects/delegate/src/extensions/module.rb
foobara-0.0.21 projects/delegate/src/extensions/module.rb
foobara-0.0.20 projects/delegate/src/extensions/module.rb
foobara-0.0.19 projects/delegate/src/extensions/module.rb
foobara-0.0.18 projects/delegate/src/extensions/module.rb
foobara-0.0.17 projects/delegate/src/extensions/module.rb
foobara-0.0.16 projects/delegate/src/extensions/module.rb
foobara-0.0.15 projects/delegate/src/extensions/module.rb
foobara-0.0.14 projects/delegate/src/extensions/module.rb
foobara-0.0.13 projects/delegate/src/extensions/module.rb
foobara-0.0.12 projects/delegate/src/extensions/module.rb
foobara-0.0.11 projects/delegate/src/extensions/module.rb
foobara-0.0.10 projects/delegate/src/extensions/module.rb
foobara-0.0.9 projects/delegate/src/extensions/module.rb
foobara-0.0.8 projects/delegate/src/extensions/module.rb
foobara-0.0.7 projects/delegate/src/extensions/module.rb