Class: Bitia::ApiController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Bitia::ApiController
- Includes:
- ActionController::MimeResponds, Resourceable
- Defined in:
- app/controllers/bitia/api_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #pure_filter(param) ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
37 38 39 40 |
# File 'app/controllers/bitia/api_controller.rb', line 37 def create pure_create_or_update render end |
#destroy ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/bitia/api_controller.rb', line 47 def destroy resource resource.destroy! render end |
#index ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/bitia/api_controller.rb', line 14 def index all = resources.count if params.include? :offset instance_variable_set("@#{resources_name}", resources.offset(params[:offset])) end if params.include? :limit instance_variable_set("@#{resources_name}", resources.limit(Integer(params[:limit]))) end [:all] = all unless [:all] render end |
#new ⇒ Object
27 28 29 30 |
# File 'app/controllers/bitia/api_controller.rb', line 27 def new resource render end |
#pure_filter(param) ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/bitia/api_controller.rb', line 54 def pure_filter(param) return unless params[param].present? instance_variable_get("@#{resources_name}").where!(param => params[param]) end |
#show ⇒ Object
32 33 34 35 |
# File 'app/controllers/bitia/api_controller.rb', line 32 def show resource render end |
#update ⇒ Object
42 43 44 45 |
# File 'app/controllers/bitia/api_controller.rb', line 42 def update pure_create_or_update render end |