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.



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/aye_commander/ivar.rb', line 86

def method_missing(name, *args)
  if name[-1] == self.class.eq
    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