Module: SingletonAttr
Overview
Adds methods to declare attribute accessors/readers/writers on singletons.
Defined Under Namespace
Instance Method Summary collapse
-
#alias_singleton_method(alias_name, method_name) ⇒ Object
alias_singleton_method #.
-
#singleton_attr_accessor(name, ...) ⇒ Module, Class
(also: #attr_singleton_accessor)
Define an attribute accessor on the singleton of instance for which method is called.
-
#singleton_attr_reader(name, ...) ⇒ Module, Class
(also: #attr_singleton_reader)
Define an attribute reader on the singleton of instance for which method is called.
-
#singleton_attr_writer(name, ...) ⇒ Module, Class
(also: #attr_singleton_writer)
Define an attribute writer on the singleton of instance for which method is called.
Instance Method Details
#alias_singleton_method(alias_name, method_name) ⇒ Object
alias_singleton_method #
99 100 101 102 103 104 105 |
# File 'lib/singleton_attr.rb', line 99 def alias_singleton_method( alias_name, method_name ) singleton_class.instance_eval { alias_method alias_name, method_name } return self end |
#singleton_attr_accessor(name, ...) ⇒ Module, Class Also known as: attr_singleton_accessor
Define an attribute accessor on the singleton of instance for which method is called.
23 24 25 26 27 28 29 |
# File 'lib/singleton_attr.rb', line 23 def singleton_attr_accessor( *names ) singleton_class.instance_eval { attr_accessor *names } return self end |
#singleton_attr_reader(name, ...) ⇒ Module, Class Also known as: attr_singleton_reader
Define an attribute reader on the singleton of instance for which method is called.
52 53 54 55 56 57 58 |
# File 'lib/singleton_attr.rb', line 52 def singleton_attr_reader( *names ) singleton_class.instance_eval { attr_reader *names } return self end |
#singleton_attr_writer(name, ...) ⇒ Module, Class Also known as: attr_singleton_writer
Define an attribute writer on the singleton of instance for which method is called.
81 82 83 84 85 86 87 |
# File 'lib/singleton_attr.rb', line 81 def singleton_attr_writer( *names ) singleton_class.instance_eval { attr_writer *names } return self end |