Class: Api::V2::TemplateInputsController

Inherits:
BaseController
  • Object
show all
Includes:
Api::Version2, Foreman::Renderer
Defined in:
app/controllers/api/v2/template_inputs_controller.rb

Instance Method Summary collapse

Instance Method Details

#action_permissionObject



70
71
72
73
74
75
76
77
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 70

def action_permission
  case params[:action]
  when :create, :edit, :destroy
    'edit'
  else
    super
  end
end

#controller_permissionObject



66
67
68
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 66

def controller_permission
  'templates'
end

#createObject



42
43
44
45
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 42

def create
  @template_input = resource_class.new(params[:template_input].merge(:template_id => @nested_obj.id))
  process_response @template_input.save
end

#destroyObject



50
51
52
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 50

def destroy
  process_response @template_input.destroy
end

#indexObject



14
15
16
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 14

def index
  @template_inputs = nested_obj.template_inputs.search_for(*search_options).paginate(paginate_options)
end

#resource_name(nested_resource = nil) ⇒ Object



62
63
64
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 62

def resource_name(nested_resource = nil)
  nested_resource || 'template_input'
end

#showObject



21
22
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 21

def show
end

#updateObject



58
59
60
# File 'app/controllers/api/v2/template_inputs_controller.rb', line 58

def update
  process_response @template_input.update_attributes(params[:template_input])
end