Module: ForemanOpenstackSimplify::ControllerPatches
- Defined in:
- lib/foreman_openstack_simplify/controller_patches.rb
Class Method Summary collapse
- .not_implemented(controller_class, method_names, type = :text) ⇒ Object
- .not_implemented_api_crud(controller_class, skip_find_resource = true) ⇒ Object
- .not_implemented_ui_crud(controller_class) ⇒ Object
Class Method Details
.not_implemented(controller_class, method_names, type = :text) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/foreman_openstack_simplify/controller_patches.rb', line 4 def not_implemented(controller_class, method_names, type = :text) controller_class.class_eval do method_names.each do |method_name| case type when :text define_method(method_name) do render :text => "Not Implemented", :status => :not_implemented end when :json define_method(method_name) do render :json => '{"error":{"message":"Not Implemented"}}', :status => :not_implemented end else raise ArgumentError, "Wrong response type '#{type.to_s}'" end end end end |
.not_implemented_api_crud(controller_class, skip_find_resource = true) ⇒ Object
28 29 30 31 32 |
# File 'lib/foreman_openstack_simplify/controller_patches.rb', line 28 def not_implemented_api_crud(controller_class, skip_find_resource = true) not_implemented(controller_class, [:index, :show, :create, :update, :destroy], :json) controller_class.skip_filter :find_resource if skip_find_resource end |
.not_implemented_ui_crud(controller_class) ⇒ Object
23 24 25 26 |
# File 'lib/foreman_openstack_simplify/controller_patches.rb', line 23 def not_implemented_ui_crud(controller_class) not_implemented(controller_class, [:index, :show, :new, :create, :edit, :update, :destroy]) end |