Class: Frise::Loader::Lazy

Inherits:
BasicObject
Defined in:
lib/frise/loader/lazy.rb

Overview

A basic proxy object.

Instance Method Summary collapse

Constructor Details

#initialize(&callable) ⇒ Lazy

Returns a new instance of Lazy.



7
8
9
# File 'lib/frise/loader/lazy.rb', line 7

def initialize(&callable)
  @callable = callable
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



15
16
17
# File 'lib/frise/loader/lazy.rb', line 15

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

Instance Method Details

#__target_object__Object



11
12
13
# File 'lib/frise/loader/lazy.rb', line 11

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

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/frise/loader/lazy.rb', line 19

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