+
+ def scopes_allow?(req_s)
+ scopes.each do |scope|
+ return true if (scope == 'all') or (scope == req_s) or
+ ((scope.end_with? '/') and (req_s.start_with? scope))
+ end
+ false
+ end
+
+ def scopes_allow_request?(request)
+ scopes_allow? [request.request_method, request.path].join(' ')
+ end
+
+ def logged_attributes
+ attrs = attributes.dup
+ attrs.delete('api_token')
+ attrs
+ end
+
+ def self.default_orders
+ ["#{table_name}.id desc"]
+ end
+
+ protected
+
+ def permission_to_create
+ current_user.andand.is_admin or (current_user.andand.id == self.user_id)
+ end
+
+ def permission_to_update
+ (permission_to_create and
+ not self.user_id_changed? and
+ not self.owner_uuid_changed?)
+ end
+
+ def log_update
+ super unless (changed - UNLOGGED_CHANGES).empty?
+ end