Module: ActiveSupport::Dependencies

Defined in:
lib/active_support_decorators/dependencies_patch.rb

Instance Method Summary collapse

Instance Method Details

#require_or_load(file_name, const_path = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_support_decorators/dependencies_patch.rb', line 7

def require_or_load(file_name, const_path = nil)
  if ActiveSupportDecorators.is_decorator?(file_name)
    # If an attempt is made to load the decorator file (such as eager loading), we
    # need to load the original file and then the decorators.
    original_const_name = ActiveSupportDecorators.original_const_name(file_name)

    if original_const_name
      ActiveSupportDecorators.log "Decorators: Expecting #{file_name} to decorate #{original_const_name}."
      original_const_name.constantize

      ActiveSupportDecorators.all(file_name, const_path).each do |d|
        ActiveSupportDecorators.log "Decorators: Loading #{d} for #{file_name}."
        require_or_load_single(d)
      end

    else
      ActiveSupportDecorators.log "Decorators: Nothing found to load before: #{file_name}."
      require_or_load_single(file_name)
    end

  else
    require_or_load_single(file_name, const_path)

    ActiveSupportDecorators.all(file_name, const_path).each do |d|
      ActiveSupportDecorators.log "Decorators: Loading #{d} for #{file_name}."
      require_or_load_single(d)
    end
  end
end

#require_or_load_singleObject



5
# File 'lib/active_support_decorators/dependencies_patch.rb', line 5

alias_method :require_or_load_single, :require_or_load