Sha256: 0eac801fbb4880e355ff763729c72ace57154a2c2e0cda4e0dc88e415ae41087

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

module ResourceController
  module Controller    
    def self.included(subclass)
      subclass.class_eval do
        include ResourceController::Helpers
        extend  ResourceController::Accessors
        
        before_filter :load_collection, :only => [:index]
        before_filter :build_object, :only => [:new, :create]
        before_filter :load_object, :only => [:show, :create, :update, :new, :edit, :destroy]
        
        class_reader_writer :belongs_to, *NAME_ACCESSORS
        NAME_ACCESSORS.each { |accessor| send(accessor, controller_name.singularize.underscore) }

        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
        
    private
      def self.init_default_actions(klass)
        klass.class_eval do
          class << self
            def singleton?
              false
            end
          end
        end
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
matid-resource_controller-0.7.2 lib/resource_controller/controller.rb
matid-resource_controller-0.7.1 lib/resource_controller/controller.rb
matid-resource_controller-0.7.0 lib/resource_controller/controller.rb
matid-resource_controller-0.6.7 lib/resource_controller/controller.rb
matid-resource_controller-0.6.6 lib/resource_controller/controller.rb
matid-resource_controller-0.6.5 lib/resource_controller/controller.rb