Module: NubeController
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/nube/controllers/nube_controller.rb
Instance Method Summary collapse
- #count ⇒ Object
- #create ⇒ Object
- #destroy_all ⇒ Object
- #empty_attributes ⇒ Object
- #index ⇒ Object
- #massive_creation ⇒ Object
- #massive_sum ⇒ Object
- #massive_update ⇒ Object
- #resource ⇒ Object
- #update ⇒ Object
- #update_all ⇒ Object
Instance Method Details
#count ⇒ Object
12 |
# File 'lib/nube/controllers/nube_controller.rb', line 12 def count; render json: apply_scopes.count; end |
#create ⇒ Object
14 15 16 17 |
# File 'lib/nube/controllers/nube_controller.rb', line 14 def create obj = resource.create(attributes) render json: { object: obj.attributes, errors: obj.errors. } end |
#destroy_all ⇒ Object
27 |
# File 'lib/nube/controllers/nube_controller.rb', line 27 def destroy_all; render json: apply_scopes.destroy_all; end |
#empty_attributes ⇒ Object
35 |
# File 'lib/nube/controllers/nube_controller.rb', line 35 def empty_attributes; render json: resource.new ; end |
#index ⇒ Object
8 9 10 |
# File 'lib/nube/controllers/nube_controller.rb', line 8 def index render json: apply_scopes end |
#massive_creation ⇒ Object
33 |
# File 'lib/nube/controllers/nube_controller.rb', line 33 def massive_creation; resource.massive_creation(transaction); end |
#massive_sum ⇒ Object
29 |
# File 'lib/nube/controllers/nube_controller.rb', line 29 def massive_sum; resource.massive_sum(transaction); end |
#massive_update ⇒ Object
31 |
# File 'lib/nube/controllers/nube_controller.rb', line 31 def massive_update; resource.massive_update(transaction); end |
#resource ⇒ Object
4 5 6 |
# File 'lib/nube/controllers/nube_controller.rb', line 4 def resource defined?(self.class::RESOURCE) ? self.class::RESOURCE : controller_name.singularize.camelize.constantize end |
#update ⇒ Object
19 20 21 22 23 |
# File 'lib/nube/controllers/nube_controller.rb', line 19 def update obj = resource.find(params[:id]) obj.update_attributes(attributes) render json: obj.errors. end |
#update_all ⇒ Object
25 |
# File 'lib/nube/controllers/nube_controller.rb', line 25 def update_all; render json: apply_scopes.update_all(params[:changes]); end |