Module: ResourceController::Controller

Defined in:
lib/resource_controller/controller.rb

Class Method Summary collapse

Class Method Details

.included(subclass) ⇒ Object



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
# File 'lib/resource_controller/controller.rb', line 3

def self.included(subclass)
  subclass.class_eval do
    include ResourceController::Helpers
    include ResourceController::Actions
    extend  ResourceController::Accessors
    extend  ResourceController::ClassMethods
    
    class_reader_writer :belongs_to, *NAME_ACCESSORS
    NAME_ACCESSORS.each { |accessor| send(accessor, controller_name.singularize.underscore) }

    ACTIONS.each do |action|
      class_scoping_reader action, FAILABLE_ACTIONS.include?(action) ? ResourceController::FailableActionOptions.new : ResourceController::ActionOptions.new
    end

    self.helper_method :object_url, :edit_object_url, :new_object_url, :collection_url, :object, :collection, 
                         :parent, :parent_type, :parent_object, :parent_model, :model_name, :model, :object_path, 
                         :edit_object_path, :new_object_path, :collection_path, :hash_for_collection_path, :hash_for_object_path, 
                            :hash_for_edit_object_path, :hash_for_new_object_path, :hash_for_collection_url, 
                              :hash_for_object_url, :hash_for_edit_object_url, :hash_for_new_object_url, :parent?,
                                :collection_url_options, :object_url_options, :new_object_url_options
                            
  end
  
  init_default_actions(subclass)
end