Sha256: ae6fdcec829e3a7185414f4a3f721559ce2fc90ab7e57389a43ae71c6f55d296

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

require 'type_cartographer'
require 'authorization/v<%= api_version %>/<%= HorsePower.get_singular(resource_name) %>'

class <%= HorsePower.get_camel(resource_name) %> < ActiveRecord::Base

	#Controller logic

	def showAll(<%= HorsePower.get_plural(resource_name) %>,current_user)
		all_<%= HorsePower.get_plural(resource_name) %> = [];
    ActiveRecord::Base.transaction do
      <%= HorsePower.get_plural(resource_name) %>.each do |<%= HorsePower.get_singular(resource_name) %>|
        if !::Authorization::V<%= api_version %>::<%= HorsePower.get_camel(resource_name) %>.show?(<%= HorsePower.get_singular(resource_name) %>,current_user)
          all_<%= HorsePower.get_plural(resource_name) %> = nil
          raise ActiveRecord::Rollback
        end
        all_<%= HorsePower.get_plural(resource_name) %>.push(<%= HorsePower.get_singular(resource_name) %>)
      end
    end
    return all_<%= HorsePower.get_plural(resource_name) %>;
	end

	def destroyAll(<%= HorsePower.get_plural(resource_name) %>,current_user)
		obj = {}
    ActiveRecord::Base.transaction do
      <%= HorsePower.get_plural(resource_name) %>.each do |<%= HorsePower.get_singular(resource_name) %>|
        if !::Authorization::V<%= api_version %>::<%= HorsePower.get_camel(resource_name) %>.destroy?(<%= HorsePower.get_singular(resource_name) %>,current_user)
          obj = nil
          raise ActiveRecord::Rollback
        end
        <%= HorsePower.get_singular(resource_name) %>.destroy
      end
    end
    return obj
	end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
horse_power-1.0.0 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.9.0 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.8.5 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.8.3 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.8.2 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.8.1 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.8.0 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.7.1 lib/generators/horse_power/model/templates/model.rb.erb
horse_power-0.7.0 lib/generators/horse_power/model/templates/model.rb.erb