Module: AyeCommander::Ivar::ClassMethods
- Included in:
- Command::ClassMethods, Resultable::Result::ClassMethods
- Defined in:
- lib/aye_commander/ivar.rb
Overview
Instance variable related class methods
Instance Method Summary collapse
-
#define_missing_reader(reader) ⇒ Object
Adds the received reader to the class.
-
#to_ivar(name) ⇒ Object
Transforms the received name to instance variable form Eg: command -> @command.
-
#to_nvar(name) ⇒ Object
Transforms the received name to normal variable form Eg: @command -> command.
Instance Method Details
#define_missing_reader(reader) ⇒ Object
Adds the received reader to the class. It prefers using ‘uses’ it available (command), but will use attr_reader if it isn’t (result).
10 11 12 |
# File 'lib/aye_commander/ivar.rb', line 10 def define_missing_reader(reader) respond_to?(:uses) ? uses(reader) : attr_reader(reader) end |
#to_ivar(name) ⇒ Object
Transforms the received name to instance variable form Eg: command -> @command
16 17 18 |
# File 'lib/aye_commander/ivar.rb', line 16 def to_ivar(name) name[0] == '@' ? name.to_sym : "@#{name}".to_sym end |
#to_nvar(name) ⇒ Object
Transforms the received name to normal variable form Eg: @command -> command
22 23 24 |
# File 'lib/aye_commander/ivar.rb', line 22 def to_nvar(name) name[0] == '@' ? name[1..-1].to_sym : name.to_sym end |