Module: InheritanceHelper::Methods
- Defined in:
- lib/inheritance-helper/methods.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.redefine_class_method(klass, method, value) ⇒ Object
5 6 7 8 |
# File 'lib/inheritance-helper/methods.rb', line 5 def self.redefine_class_method(klass, method, value) class << klass; self; end.send(:define_method, method) { value } klass end |
Instance Method Details
#add_value_to_class_method(method, value) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/inheritance-helper/methods.rb', line 14 def add_value_to_class_method(method, value) old_value = send(method) new_value = case old_value when Hash old_value.merge(value) else old_value + Array(value) end redefine_class_method(method, old_value.frozen? ? new_value.freeze : new_value) end |
#redefine_class_method(method, value) ⇒ Object
10 11 12 |
# File 'lib/inheritance-helper/methods.rb', line 10 def redefine_class_method(method, value) ::InheritanceHelper::Methods.redefine_class_method(self, method, value) end |