aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependency_module.rb
blob: 9872b9654b3fefb097241ff146b36cd353c45504 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module ActiveSupport
  module DependencyModule
    def append_features(base)
      return if base < self
      (@_dependencies ||= []).each { |dep| base.send(:include, dep) }
      super
      base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
      base.class_eval(&@_included_block) if instance_variable_defined?("@_included_block")
    end

    def included(base = nil, &block)
      if base.nil?
        @_included_block = block
      else
        super
      end
    end

    def depends_on(*mods)
      mods.each do |mod|
        next if self < mod
        @_dependencies ||= []
        @_dependencies << mod
      end
    end
  end
end