Class: Yaoc::Helper::ToProcDelegator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/yaoc/helper/to_proc_delegator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_initialisation_proc) ⇒ ToProcDelegator

Returns a new instance of ToProcDelegator.



8
9
10
11
12
13
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 8

def initialize(_initialisation_proc)
  super(nil).tap do
    self._initialisation_proc = _initialisation_proc
    self._initialisation_proc_loaded = false
  end
end

Instance Attribute Details

#_initialisation_procObject

Returns the value of attribute _initialisation_proc.



6
7
8
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 6

def _initialisation_proc
  @_initialisation_proc
end

#_initialisation_proc_loadedObject

Returns the value of attribute _initialisation_proc_loaded.



6
7
8
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 6

def _initialisation_proc_loaded
  @_initialisation_proc_loaded
end

Instance Method Details

#__getobj__Object



16
17
18
19
20
21
22
23
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 16

def __getobj__
  unless self._initialisation_proc_loaded
    self._initialisation_proc_loaded = true
    __setobj__(self._initialisation_proc.call())
  end

  super
end

#_initialisation_proc_loaded?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 37

def _initialisation_proc_loaded?
  self._initialisation_proc_loaded
end

#_needs_conversion?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 41

def _needs_conversion?
  _initialisation_proc_loaded? && ! nil?
end

#classObject



25
26
27
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 25

def class
  __getobj__.class
end

#kind_of?(some_class) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 29

def kind_of?(some_class)
  super || __getobj__.kind_of?(some_class)
end

#nil?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/yaoc/helper/to_proc_delegator.rb', line 33

def nil?
  __getobj__.nil?
end