Module: Ducktape::Hookable
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary
collapse
Class Method Details
.extended(_) ⇒ Object
27
28
29
|
# File 'lib/ducktape/hookable.rb', line 27
def self.extended(_)
raise 'Cannot extend, only include.'
end
|
.included(base) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/ducktape/hookable.rb', line 3
def self.included(base)
if base.is_a?(Class)
base.include InstanceMethods
base.extend ClassMethods
base.def_hook(:on_changed) unless base.method_defined?(:on_changed)
return
end
include_method = if base.respond_to?(:included)
base_included_method = base.method(:included)
->(c) do
base_included_method.(c)
c.send :include, ::Ducktape::Hookable
end
else
->(c) { c.send :include, ::Ducktape::Hookable }
end
base.define_singleton_method(:included, include_method)
end
|