diff --git a/helpers/application_helper.rb b/helpers/application_helper.rb index 04999f65..ad813e31 100644 --- a/helpers/application_helper.rb +++ b/helpers/application_helper.rb @@ -125,10 +125,10 @@ def reply(*response) check_access(obj) if LinkedData.settings.enable_security # Slice or set check - filter_for_slice(obj) if LinkedData.settings.enable_slices + obj = filter_for_slice(obj) if LinkedData.settings.enable_slices # Check for custom ontologies set by user - filter_for_user_onts(obj) + obj = filter_for_user_onts(obj) LinkedData::Serializer.build_response(@env, status: status, ld_object: obj) end @@ -211,8 +211,8 @@ def restricted_ontologies(params=nil) found_onts = onts.length > 0 - filter_for_slice(onts) - filter_for_user_onts(onts) + onts = filter_for_slice(onts) + onts = filter_for_user_onts(onts) end onts = filter_access(onts) diff --git a/helpers/slices_helper.rb b/helpers/slices_helper.rb index d17db53e..6f527f29 100644 --- a/helpers/slices_helper.rb +++ b/helpers/slices_helper.rb @@ -10,10 +10,8 @@ def filter_for_slice(obj) slice = current_slice() - if obj.is_a?(Enumerable) - if obj.first.is_a?(LinkedData::Models::Ontology) - obj.delete_if {|o| !slice.ontology_id_set.include?(o.id.to_s)} - end + if obj.is_a?(Enumerable) && obj.first.is_a?(LinkedData::Models::Ontology) + obj = obj.select { |o| slice.ontology_id_set.include?(o.id.to_s) } end obj end @@ -35,4 +33,4 @@ def current_slice_acronyms end end -helpers Sinatra::Helpers::SlicesHelper \ No newline at end of file +helpers Sinatra::Helpers::SlicesHelper diff --git a/helpers/users_helper.rb b/helpers/users_helper.rb index 5d4266c1..eeb6f800 100644 --- a/helpers/users_helper.rb +++ b/helpers/users_helper.rb @@ -12,7 +12,7 @@ def filter_for_user_onts(obj) user = env["REMOTE_USER"] if obj.first.is_a?(LinkedData::Models::Ontology) - obj.delete_if {|o| !user.custom_ontology_id_set.include?(o.id.to_s)} + obj = obj.select {|o| user.custom_ontology_id_set.include?(o.id.to_s)} end obj @@ -21,4 +21,4 @@ def filter_for_user_onts(obj) end end -helpers Sinatra::Helpers::UsersHelper \ No newline at end of file +helpers Sinatra::Helpers::UsersHelper