Created
December 17, 2009 14:40
-
-
Save banyan/258783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
class ReportAccess | |
def who_can_see(user_names, allowed_data, report_data) | |
h = {} | |
allowed_data.each_with_index do | data, i | | |
data.split(/ /).each do | v | | |
h[i] = user_names[i] unless report_data.index(v).nil? | |
end | |
end | |
return h.values | |
end | |
end | |
ra = ReportAccess.new | |
p ra.who_can_see(["usrA","usrB","usrC"], ["data1 data3","data2 data4","data3 data5 data6"], ["data1"]) | |
p ra.who_can_see(["kathy", "john", "dan", "steve", "cheryl", "tony"], ["users data", "data orders", "users permissions", "system users controls", "default", "admin users"], ["users"]) | |
p ra.who_can_see(["jim", "scott", "barbara"], ["users order products", "products shipping", "tracking products orders"], ["admin"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment