Module: ActionController::Dependencies::ClassMethods

Defined in:
lib/action_controller/deprecated_dependencies.rb

Overview

Deprecated module. The responsibility of loading dependencies belong with Active Support now.

Instance Method Summary collapse

Instance Method Details

#depend_on(layer, dependencies) ⇒ Object

:nodoc:



41
42
43
# File 'lib/action_controller/deprecated_dependencies.rb', line 41

def depend_on(layer, dependencies) #:nodoc:
  write_inheritable_array("#{layer}_dependencies", dependencies)
end

#dependencies_on(layer) ⇒ Object

Returns an array of symbols that specify the dependencies on a given layer. For the example at the top, calling ApplicationController.dependencies_on(:model) would return [:account, :company, :person, :project, :category]



36
37
38
# File 'lib/action_controller/deprecated_dependencies.rb', line 36

def dependencies_on(layer)
  read_inheritable_attribute("#{layer}_dependencies")
end

#model(*models) ⇒ Object

Specifies a variable number of models that this controller depends on. Models are normally Active Record classes or a similar backend for modelling entity classes.



11
12
13
14
# File 'lib/action_controller/deprecated_dependencies.rb', line 11

def model(*models)
  require_dependencies(:model, models)
  depend_on(:model, models)
end

#observer(*observers) ⇒ Object

Specifies a variable number of observers that are to govern when this controller is handling actions. The observers will automatically have .instance called on them to make them active on assignment.



27
28
29
30
31
# File 'lib/action_controller/deprecated_dependencies.rb', line 27

def observer(*observers)
  require_dependencies(:observer, observers)
  depend_on(:observer, observers)
  instantiate_observers(observers)
end

#service(*services) ⇒ Object

Specifies a variable number of services that this controller depends on. Services are normally singletons or factories, like Action Mailer service or a Payment Gateway service.



19
20
21
22
# File 'lib/action_controller/deprecated_dependencies.rb', line 19

def service(*services)
  require_dependencies(:service, services)
  depend_on(:service, services)
end