Sha256: ef30ceed15131f592c20ee766e3af8f348e3056e2b9b1f87ce7916ef6c8ec74f

Contents?: true

Size: 738 Bytes

Versions: 42

Compression:

Stored size: 738 Bytes

Contents

module Eco
  module Language
    module Methods
      module DelegateMissing
        def delegate_missing_to(meth)
          @delegate_missing_to = meth
        end

        def method_missing(method_name, *args, **kargs, &block)
          super unless receiver = object_missing_delegated_to
          receiver.send(method_name, *args, **kargs, &block)
        end

        def respond_to_missing?(method_name, include_private = false)
          super
        end

        private

        # retrieve the delegate_missing_to object
        def object_missing_delegated_to
          return nil unless @delegate_missing_to
          self.method(@delegate_missing_to).call
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
eco-helpers-2.6.2 lib/eco/language/methods/delegate_missing.rb
eco-helpers-2.6.1 lib/eco/language/methods/delegate_missing.rb