module AyeCommander::Ivar::Readable
Helps a command and result respond to read methods of instance variables This functionality is divided into two different modules since commander includes both, but result only includes Readable
Public Instance Methods
method_missing(name, *args)
click to toggle source
A command will only respond to a read instance variable if it receives a valid instance variable name that is already defined within the command or result.
Calls superclass method
# File lib/aye_commander/ivar.rb, line 45 def method_missing(name, *args) var_name = to_ivar(name) if instance_variable_defined? var_name self.class.define_missing_reader(name) instance_variable_get var_name else super end rescue NameError super end
remove!(name)
click to toggle source
This helps remove an instance variable name from the current command. Consider using the .returns method instead.
# File lib/aye_commander/ivar.rb, line 59 def remove!(name) remove_instance_variable to_ivar(name) end
to_ivar(name)
click to toggle source
Transforms the received name to instance variable form
# File lib/aye_commander/ivar.rb, line 64 def to_ivar(name) self.class.to_ivar(name) end
to_nvar(name)
click to toggle source
Transforms the received name to normal variable form
# File lib/aye_commander/ivar.rb, line 69 def to_nvar(name) self.class.to_nvar(name) end
Private Instance Methods
respond_to_missing?(name, *args)
click to toggle source
Calls superclass method
# File lib/aye_commander/ivar.rb, line 75 def respond_to_missing?(name, *args) instance_variable_defined?(to_ivar(name)) || super rescue NameError super end