Class: Sbmt::Outbox::Api::OutboxClassesController

Inherits:
BaseController show all
Defined in:
app/controllers/sbmt/outbox/api/outbox_classes_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/sbmt/outbox/api/outbox_classes_controller.rb', line 27

def destroy
  record = Api::OutboxClass.find(params.require(:id))
  unless record
    render_ok
    return
  end

  record.destroy

  render_one record
end

#indexObject



7
8
9
10
11
# File 'app/controllers/sbmt/outbox/api/outbox_classes_controller.rb', line 7

def index
  render_list(Sbmt::Outbox.outbox_item_classes.map do |item|
    Api::OutboxClass.find_or_initialize(item.box_id)
  end)
end

#showObject



13
14
15
# File 'app/controllers/sbmt/outbox/api/outbox_classes_controller.rb', line 13

def show
  render_one Api::OutboxClass.find_or_initialize(params.require(:id))
end

#updateObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/sbmt/outbox/api/outbox_classes_controller.rb', line 17

def update
  record = Api::OutboxClass.find_or_initialize(params.require(:id))
  record.assign_attributes(
    params.require(:outbox_class).permit(:polling_enabled)
  )
  record.save

  render_one record
end