lib/avo/base_resource.rb in avo-3.0.0.pre7 vs lib/avo/base_resource.rb in avo-3.0.0.pre8
- old
+ new
@@ -51,13 +51,11 @@
class_attribute :scopes_loader
class_attribute :filters_loader
class_attribute :grid_loader
class_attribute :visible_on_sidebar, default: true
class_attribute :unscoped_queries_on_index, default: false
- class_attribute :resolve_index_query
- class_attribute :resolve_find_scope
- # TODO: refactor this into a Host without args
+ class_attribute :index_query
class_attribute :find_record_method, default: -> {
query.find id
}
class_attribute :hide_from_global_search, default: false
class_attribute :after_create_path, default: :show
@@ -109,27 +107,21 @@
end
end
# This resolves the scope when doing "where" queries (not find queries)
def query_scope
- final_scope = if resolve_index_query.present?
- Avo::ExecutionContext.new(target: resolve_index_query, query: model_class).handle
+ final_scope = if index_query.present?
+ Avo::ExecutionContext.new(target: index_query, query: model_class).handle
else
model_class
end
authorization.apply_policy final_scope
end
# This resolves the scope when finding records (not "where" queries)
def find_scope
- final_scope = if resolve_find_scope.present?
- Avo::ExecutionContext.new(target: resolve_find_scope, query: model_class).handle
- else
- model_class
- end
-
- authorization.apply_policy final_scope
+ authorization.apply_policy model_class
end
def authorization
Avo::Services::AuthorizationService.new Avo::Current.current_user, model_class, policy_class: authorization_policy
end