Module: NubeController

Extended by:
ActiveSupport::Concern
Defined in:
lib/nube/controllers/nube_controller.rb

Instance Method Summary collapse

Instance Method Details

#countObject



12
# File 'lib/nube/controllers/nube_controller.rb', line 12

def count; render json: apply_scopes.count; end

#createObject



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.messages }
end

#destroy_allObject



27
# File 'lib/nube/controllers/nube_controller.rb', line 27

def destroy_all; render json: apply_scopes.destroy_all; end

#empty_attributesObject



35
# File 'lib/nube/controllers/nube_controller.rb', line 35

def empty_attributes; render json: resource.new ; end

#indexObject



8
9
10
# File 'lib/nube/controllers/nube_controller.rb', line 8

def index
  render json: apply_scopes
end

#massive_creationObject



33
# File 'lib/nube/controllers/nube_controller.rb', line 33

def massive_creation; resource.massive_creation(transaction); end

#massive_sumObject



29
# File 'lib/nube/controllers/nube_controller.rb', line 29

def massive_sum; resource.massive_sum(transaction); end

#massive_updateObject



31
# File 'lib/nube/controllers/nube_controller.rb', line 31

def massive_update; resource.massive_update(transaction); end

#resourceObject



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

#updateObject



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.messages
end

#update_allObject



25
# File 'lib/nube/controllers/nube_controller.rb', line 25

def update_all; render json: apply_scopes.update_all(params[:changes]); end