Sha256: 8caf9c4b69ed045fafddf305ffc84723bbc8173737d9c64b015a34e658b4408a

Contents?: true

Size: 771 Bytes

Versions: 2

Compression:

Stored size: 771 Bytes

Contents

module PageEz
  module DelegatesTo
    def self.[](name)
      Module.new do
        define_singleton_method(:included) do |base|
          base.include(Module.new.tap do |mod|
            mod.class_eval %{
              def method_missing(*args, **kwargs, &block)
                if #{name}.respond_to?(args[0])
                  #{name}.send(*args, **kwargs, &block)
                else
                  super(*args, **kwargs, &block)
                end
              end

              def respond_to_missing?(method_name, include_private = false)
                #{name}.respond_to?(method_name, include_private) || super(method_name, include_private)
              end
            }, __FILE__, __LINE__ - 12
          end)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_ez-0.2.0 lib/page_ez/delegates_to.rb
page_ez-0.1.0 lib/page_ez/delegates_to.rb