Sha256: b2782b91db3b4325bc624cc8de1563a38e121b475dc9ddd8185bcb5eb253ce68

Contents?: true

Size: 657 Bytes

Versions: 2

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

module Frise
  class Loader
    # A basic proxy object.
    class Lazy < BasicObject
      def initialize(&callable)
        @callable = callable
      end

      def __target_object__
        @__target_object__ ||= @callable.call
      end

      # rubocop:disable Style/MethodMissingSuper
      def method_missing(method_name, *args, &block)
        __target_object__.send(method_name, *args, &block)
      end
      # rubocop:enable Style/MethodMissingSuper

      def respond_to_missing?(method_name, include_private = false)
        __target_object__.respond_to?(method_name, include_private)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frise-0.4.1 lib/frise/loader/lazy.rb
frise-0.4.0 lib/frise/loader/lazy.rb