Sha256: 9dd4e239a22d182dc7b753f2c9ed807765c5e679e16b33e25637e050772d0b17

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

# frozen_string_literal: true

module Lite
  module Decorator
    module Record

      def self.included(base)
        base.include Infered
      end

      private

      def method_missing(method_name, *args, **kwargs, &)
        if respond_to_method?(method_name)
          decorator.send(method_name, *args, **kwargs, &)
        else
          super
        end
      end

      def respond_to_method_cache
        @respond_to_method_cache ||= {}
      end

      def respond_to_method?(method_name)
        return respond_to_method_cache[method_name] if respond_to_method_cache.key?(method_name)

        respond_to_method_cache[method_name] = decorator.present? && decorator.public_methods.include?(method_name)
      end

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lite-decorator-2.0.0 lib/lite/decorator/record.rb