Module: Inversion::MethodUtilities
- Included in:
- Template::Tag
- Defined in:
- lib/inversion/mixins.rb
Overview
A collection of methods for declaring other methods.
class MyClass
include Inversion::MethodUtilities
singleton_attr_accessor :types
end
MyClass.types = [ :pheno, :proto, :stereo ]
Instance Method Summary collapse
-
#singleton_attr_accessor(*symbols) ⇒ Object
Creates readers and writers that allow assignment to the attributes of the singleton of the declaring object that correspond to the specified
symbols
. -
#singleton_attr_reader(*symbols) ⇒ Object
Creates instance variables and corresponding methods that return their values for each of the specified
symbols
in the singleton of the declaring object (e.g., class instance variables and methods if declared in a Class). -
#singleton_attr_writer(*symbols) ⇒ Object
Creates methods that allow assignment to the attributes of the singleton of the declaring object that correspond to the specified
symbols
.
Instance Method Details
#singleton_attr_accessor(*symbols) ⇒ Object
Creates readers and writers that allow assignment to the attributes of the singleton of the declaring object that correspond to the specified symbols
.
218 219 220 221 222 |
# File 'lib/inversion/mixins.rb', line 218 def singleton_attr_accessor( *symbols ) symbols.each do |sym| singleton_class.__send__( :attr_accessor, sym ) end end |
#singleton_attr_reader(*symbols) ⇒ Object
Creates instance variables and corresponding methods that return their values for each of the specified symbols
in the singleton of the declaring object (e.g., class instance variables and methods if declared in a Class).
201 202 203 204 205 |
# File 'lib/inversion/mixins.rb', line 201 def singleton_attr_reader( *symbols ) symbols.each do |sym| singleton_class.__send__( :attr_reader, sym ) end end |
#singleton_attr_writer(*symbols) ⇒ Object
Creates methods that allow assignment to the attributes of the singleton of the declaring object that correspond to the specified symbols
.
209 210 211 212 213 |
# File 'lib/inversion/mixins.rb', line 209 def singleton_attr_writer( *symbols ) symbols.each do |sym| singleton_class.__send__( :attr_writer, sym ) end end |