lib/recurso/policies/resource_policy.rb in recurso-0.5.3 vs lib/recurso/policies/resource_policy.rb in recurso-0.6.1
- old
+ new
@@ -5,26 +5,17 @@
super unless Recurso::Config.instance.levels_for_action.keys.include?(action)
Recurso::Queries::Single.new(identity, resource, action).permission?
end
- def resources_with_permission(relation_name, all_columns: true, include_actions: [:modify, :administer])
- include_actions.reduce(resource_query_for(relation_name, :view, all_columns: all_columns)) do |resources, action|
- resources
- .joins("LEFT OUTER JOIN(#{resource_query_for(relation_name, action).to_sql}) AS #{action} ON #{action}.id = #{relation_name}.id")
- .select("#{action}.id IS NOT NULL AS can_#{action}")
- end
- end
-
- private
-
- def resource_query_for(relation_name, action, all_columns: false)
+ def resources_with_permission(relation_name, action: :view, all_columns: true, include_actions: [:modify, :administer])
Recurso::Queries::Relation.new(
identity,
resource,
relation_name,
all_columns: all_columns,
- action: action
+ action: action,
+ include_actions: include_actions,
).resources
end
end
end