Class: ConvenientService::Utils::Object::MemoizeIncludingFalsyValues Private

Inherits:
Support::Command
  • Object
show all
Defined in:
lib/convenient_service/utils/object/memoize_including_falsy_values.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

false and nil are the only values that are considered falsy in Ruby.

Can be used instead of return @ivar if defined? @ivar.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(object, ivar_name, &value_block) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • object (Object)
  • ivar_name (Symbol)
  • value_block (Proc)

Since:

  • 1.0.0



48
49
50
51
52
# File 'lib/convenient_service/utils/object/memoize_including_falsy_values.rb', line 48

def initialize(object, ivar_name, &value_block)
  @object = object
  @ivar_name = ivar_name
  @value_block = value_block
end

Instance Attribute Details

#ivar_nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



34
35
36
# File 'lib/convenient_service/utils/object/memoize_including_falsy_values.rb', line 34

def ivar_name
  @ivar_name
end

#objectObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



28
29
30
# File 'lib/convenient_service/utils/object/memoize_including_falsy_values.rb', line 28

def object
  @object
end

#value_blockObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



40
41
42
# File 'lib/convenient_service/utils/object/memoize_including_falsy_values.rb', line 40

def value_block
  @value_block
end

Instance Method Details

#callObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Value of ivar. Can be any type.

Returns:

  • (Object)

    Value of ivar. Can be any type.

Since:

  • 1.0.0



57
58
59
# File 'lib/convenient_service/utils/object/memoize_including_falsy_values.rb', line 57

def call
  Utils::Object.instance_variable_fetch(object, ivar_name, &value_block)
end