lib/eucalypt/security/permissions.rb in eucalypt-0.7.2 vs lib/eucalypt/security/permissions.rb in eucalypt-0.8.0
- old
+ new
@@ -8,12 +8,20 @@
roles_name = "#{resource_name}_roles"
role_constant_name = roles_name.singularize.camelize
role_constant = role_constant_name.constantize
if ActiveRecord::Base.connection.table_exists? roles_name
- role_constant.pluck(:permission).each do |permission|
- policy_constant.define_method "#{permission}?" do
- role_constant.find_by(permission: permission).send(user.role.send resource_name)
+ level = ActiveRecord::Base.logger.level
+ begin
+ ActiveRecord::Base.logger.level = :unknown
+ role_constant.pluck(:permission).each do |permission|
+ policy_constant.define_method "#{permission}?" do
+ role_constant.find_by(permission: permission).send(user.role.send resource_name)
+ end
end
+ rescue => exception
+ throw exception
+ ensure
+ ActiveRecord::Base.logger.level = level
end
end
end
\ No newline at end of file