Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/module.rb
Overview
reopen Module from ActiveSupport
Instance Method Summary collapse
- #__delegate ⇒ Object
- #delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil) ⇒ Object
Instance Method Details
#__delegate ⇒ Object
5 |
# File 'lib/module.rb', line 5 alias __delegate delegate |
#delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/module.rb', line 6 def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil) if defined?(ActiveRecord::Base) && self < ActiveRecord::Base methods.each do |method| method_name = "delegated_#{"#{prefix == true ? to : prefix}_" if prefix}#{method}?" define_singleton_method(method_name) do to end define_method(method_name) do to end end end __delegate(*methods, to:, prefix:, allow_nil:, private:) end |