Sha256: bc8581cae9e10b4c393cf8c46cf47e6ec25dbe400caba3041ae1495b136252f6

Contents?: true

Size: 560 Bytes

Versions: 3

Compression:

Stored size: 560 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

      def method_missing(method_name, *args, &block)
        __target_object__.send(method_name, *args, &block)
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frise-0.6.1 lib/frise/loader/lazy.rb
frise-0.6.0 lib/frise/loader/lazy.rb
frise-0.5.1 lib/frise/loader/lazy.rb