Module: Zobi::Inherited

Defined in:
lib/zobi/inherited.rb

Overview

This module add some helpers to controllers.

* inherit_resources
* params filtering

Defined Under Namespace

Modules: Hidden

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



10
11
12
13
# File 'lib/zobi/inherited.rb', line 10

def self.included(klass)
  klass.send 'include', Inherited::Hidden
  klass.send 'respond_to', :html
end

Instance Method Details

#createObject Also known as: create!



21
22
23
24
25
26
27
# File 'lib/zobi/inherited.rb', line 21

def create
  r = zobi_resource_class.create permitted_params[zobi_resource_key]
  instance_variable_set "@#{resource_key}", r
  args = route_namespace
  args << r
  block_given? ? yield(r) : respond_with(*args)
end

#destroyObject Also known as: destroy!



38
39
40
41
# File 'lib/zobi/inherited.rb', line 38

def destroy
  resource.destroy
  block_given? ? yield(resource) : redirect_to(collection_path)
end

#editObject



18
19
# File 'lib/zobi/inherited.rb', line 18

def edit
end

#newObject



15
16
# File 'lib/zobi/inherited.rb', line 15

def new
end

#updateObject Also known as: update!



30
31
32
33
34
35
# File 'lib/zobi/inherited.rb', line 30

def update
  resource.update_attributes permitted_params[zobi_resource_key]
  args = route_namespace
  args << resource
  block_given? ? yield(resource) : respond_with(*args)
end