Module: Naming
- Defined in:
- lib/naming.rb,
lib/naming/version.rb
Overview
Naming is a module for generating naming classes that consist by name and value. Naming classes are generated dynamically when you refer it.
Defined Under Namespace
Classes: Meta
Constant Summary collapse
- VERSION =
version of this library
"0.0.1"
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
private
Generate a new naming class.
-
.method_missing(name, *args) ⇒ Object
private
Generate a new naming class and call the constructor with value.
-
.others(array) ⇒ Object
Collect objects from the array excluding naming objects.
Class Method Details
.const_missing(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate a new naming class.
147 148 149 150 151 152 153 154 155 |
# File 'lib/naming.rb', line 147 def const_missing(name) cls = Class.new(Meta) self.singleton_class.class_exec do define_method(name) do |value| cls.new(value) end end const_set(name, cls) end |
.method_missing(name, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate a new naming class and call the constructor with value.
139 140 141 142 |
# File 'lib/naming.rb', line 139 def method_missing(name, *args) const_get(name) send(name, *args) end |
.others(array) ⇒ Object
Collect objects from the array excluding naming objects.
171 172 173 |
# File 'lib/naming.rb', line 171 def others(array) array.select{|elt| not(elt.kind_of?(Meta))} end |