Class: Manageable::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/manageable/application_controller.rb

Direct Known Subclasses

StyleguidesController

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})
  resource_class klass
  resource_vars  options[:vars]
  resource_paths options[: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