Class: Manageable::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Manageable::ApplicationController
- Defined in:
- app/controllers/manageable/application_controller.rb
Direct Known Subclasses
Class Method Summary collapse
-
.manageable_configuration(klass, options = {}) ⇒ Object
:vars => { :collection => :examples, :resource => :example }, :paths => { :collection => :examples, :resource => :example, :new => :new_example, :edit => :edit_example, }.
-
.resource_class(klass = nil) ⇒ Object
The resource class.
- .resource_paths(paths = nil) ⇒ Object
-
.resource_vars(vars = nil) ⇒ Object
The controller var names for the resource E.g.: :collection => :pages, :resource => :page.
Instance Method Summary collapse
-
#respond_with_with_storage(*args, &block) ⇒ Object
(also: #respond_with)
Custom respond_with wich stores resources for later use.
Class Method Details
.manageable_configuration(klass, options = {}) ⇒ Object
:vars => {
:collection => :examples,
:resource => :example
},
:paths => {
:collection => :examples,
:resource => :example,
:new => :new_example,
:edit => :edit_example,
}
14 15 16 17 18 |
# File 'app/controllers/manageable/application_controller.rb', line 14 def manageable_configuration(klass, = {}) resource_class klass resource_vars [:vars] resource_paths [:paths] end |
.resource_class(klass = nil) ⇒ Object
The resource class
21 22 23 24 |
# File 'app/controllers/manageable/application_controller.rb', line 21 def resource_class(klass = nil) @resource_class = klass if klass @resource_class end |
.resource_paths(paths = nil) ⇒ Object
38 39 40 41 |
# File 'app/controllers/manageable/application_controller.rb', line 38 def resource_paths(paths = nil) @resource_paths = paths if paths @resource_paths ||= {} end |
.resource_vars(vars = nil) ⇒ Object
The controller var names for the resource E.g.: :collection => :pages, :resource => :page
28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/manageable/application_controller.rb', line 28 def resource_vars(vars = nil) @resource_vars = vars if vars @resource_vars ||= begin { :resource => resource_class.model_name.element, :collection => resource_class.model_name.element.pluralize } end end |
Instance Method Details
#respond_with_with_storage(*args, &block) ⇒ Object Also known as: respond_with
Custom respond_with wich stores resources for later use
50 51 52 53 |
# File 'app/controllers/manageable/application_controller.rb', line 50 def respond_with_with_storage(*args, &block) @responded_with = args.last.is_a?(Hash) ? args - [args.last] : args respond_with_without_storage(*args, &block) end |