Module: AyeCommander::Ivar::Writeable

Included in:
Command
Defined in:
lib/aye_commander/ivar.rb

Overview

Helps a command respond to methods that would be writers

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Any method that ends with an equal sign will be able to be handled by this method missing.



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/aye_commander/ivar.rb', line 75

def method_missing(name, *args)
  if name[-1] == '='
    var_name = to_ivar(name[0...-1])
    instance_variable_set var_name, args.first
    self.class.uses name[0...-1]
  else
    super
  end
rescue NameError
  super
end