Skip to content

Instantly share code, notes, and snippets.

@dianaliu
Created October 1, 2012 19:23
Show Gist options
  • Save dianaliu/3813860 to your computer and use it in GitHub Desktop.
Save dianaliu/3813860 to your computer and use it in GitHub Desktop.
def permitted?(uid, data_model)
code = 0
if connected?(uid)
Connection.where(:user_id => uid, :conn_id => id).all(:select => 'circle_id').each do |c|
code |= Circle.find(c.circle_id).role.to_i(2)
end
elsif uid == id
return true
end
code.to_s(2)[APP_CONFIG[:data_models].reverse.index(data_model)] == "1"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment