Module: ResourceMapper::Actions

Defined in:
lib/resource_mapper/actions.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/resource_mapper/actions.rb', line 18

def create
  build_object(create_attrs)
  load_object
  before :create
  if object.save
    after :create
    response_for :create
  else
    after :create_fails
    response_for :create_fails
  end
end

#destroyObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/resource_mapper/actions.rb', line 43

def destroy
  load_object
  before :destroy
  if object.destroy
    after :destroy
    response_for :destroy
  else
    after :destroy_fails
    response_for :destroy_fails
  end
end

#indexObject



4
5
6
7
8
# File 'lib/resource_mapper/actions.rb', line 4

def index
  load_collection
  before :index
  response_for :index
end

#showObject



10
11
12
13
14
15
16
# File 'lib/resource_mapper/actions.rb', line 10

def show
  load_object
  before :show
  response_for :show
rescue #ActiveRecord::RecordNotFound
  response_for :show_fails
end

#updateObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/resource_mapper/actions.rb', line 31

def update
  load_object
  before :update
  if object.update_attributes object_params(update_attrs)
    after :update
    response_for :update
  else
    after :update_fails
    response_for :update_fails
  end
end