Sha256: 66fa5224a645726d2d686822e46bdf02025f0b8b14f48072a974a8181f5f9883
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Lite module Decorator module Record def decorator_class return @decorator_class if defined?(@decorator_class) @decorator_class = "#{self.class.name}Decorator".safe_constantize end def decorator @decorator ||= decorator_class&.new(self) 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-1.3.1 | lib/lite/decorator/record.rb |