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-3.0.19 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.18 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.17 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.16 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.15 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.14 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.13 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.12 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.11 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.10 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.9 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.8 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.7 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.6 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.5 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.4 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.3 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.2 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.1 lib/eco/language/methods/delegate_missing.rb
eco-helpers-3.0.0 lib/eco/language/methods/delegate_missing.rb