Module: CodyRobbins::EasierInstanceVariableAccess

Defined in:
lib/cody_robbins/easier_instance_variable_access.rb

Instance Method Summary collapse

Instance Method Details

#instance_variable(name) ⇒ Object Also known as: get_instance_variable

Returns the value of the specified instance variable, just like Object#instance_variable_get.

Parameters:

  • name (Symbol, String)

    The name of the instance variable to retrieve—without the leading ‘@’.

Returns:

  • The value of the specified instance variable.



9
10
11
# File 'lib/cody_robbins/easier_instance_variable_access.rb', line 9

def instance_variable(name)
  instance_variable_get(instance_variable_name(name))
end

#set_instance_variable(name, value) ⇒ Object

Sets the value of the specified instance variable, just like Object#instance_variable_set.

Parameters:

  • name (Symbol, String)

    The name of the instance variable to set—without the leading ‘@’.

  • value

    The value to set the specified instance variable to.



18
19
20
# File 'lib/cody_robbins/easier_instance_variable_access.rb', line 18

def set_instance_variable(name, value)
  instance_variable_set(instance_variable_name(name), value)
end