Module: British::Initialisable
- Defined in:
- lib/british.rb
Overview
Public: Submodule to be included in your own classes to use ‘initialise`
As far as ‘initialize` called automatically by a `new` method there is no sense to use it for third party classes.
Class Method Summary collapse
-
.included(host_class) ⇒ Object
Public: On module being included do: 1.
Class Method Details
.included(host_class) ⇒ Object
Public: On module being included do:
1. Check if it's a global include
2. Add and alias of the parent's `initialize` (for `super` calls)
3. Create your own initialize method (to be auto-called by the `new`)
Returns nothing.
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/british.rb', line 82 def self.included(host_class) unless host_class == Object # alias parent's initialise method host_class.superclass.class_eval do alias_method :initialise, :initialize end # create own initialize method define_method :initialize do |*args| initialise(*args) end end end |