Module: Darthjee::CoreExt::Class
- Included in:
- Class
- Defined in:
- lib/darthjee/core_ext/class.rb
Instance Method Summary collapse
-
#default_value(name, value) ⇒ Object
Adds a method that will return a default value.
-
#default_values(*names, value) ⇒ Object
Adds methods that will return a default value.
Instance Method Details
#default_value(name, value) ⇒ Object
Adds a method that will return a default value
the value is evaluated on class definition, meaning that everytime it is called it will be the same instance
36 37 38 |
# File 'lib/darthjee/core_ext/class.rb', line 36 def default_value(name, value) define_method(name) { |*_| value } end |
#default_values(*names, value) ⇒ Object
Adds methods that will return a default value
the value is evaluated on class definition, meaning that everytime any of them are called they will return the same instance of value
83 84 85 86 87 |
# File 'lib/darthjee/core_ext/class.rb', line 83 def default_values(*names, value) names.each do |name| default_value(name, value) end end |