Module: HalApi::Controller::Actions

Extended by:
ActiveSupport::Concern
Included in:
HalApi::Controller
Defined in:
lib/hal_api/controller/actions.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'lib/hal_api/controller/actions.rb', line 18

def create
  create_resource.tap do |res|
    consume! res, create_options
    hal_authorize res
    res.save!
    respond_with root_resource(res), create_options
  end
end

#destroyObject



36
37
38
39
40
41
42
# File 'lib/hal_api/controller/actions.rb', line 36

def destroy
  destroy_resource.tap do |res|
    hal_authorize res
    res.destroy
    head :no_content
  end
end

#indexObject



10
11
12
# File 'lib/hal_api/controller/actions.rb', line 10

def index
  respond_with index_collection, index_options
end

#showObject



14
15
16
# File 'lib/hal_api/controller/actions.rb', line 14

def show
  respond_with root_resource(show_resource), show_options
end

#updateObject



27
28
29
30
31
32
33
34
# File 'lib/hal_api/controller/actions.rb', line 27

def update
  update_resource.tap do |res|
    consume! res, show_options
    hal_authorize res
    res.save!
    respond_with root_resource(res), show_options
  end
end