aboutsummaryrefslogtreecommitdiff
blob: 9a68a8e4541682dbc06f8b12afd0e40692635fa9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# methods one_permission and multi_permission are originally authored by ahenobarbi.
# Refer to http://github.com/ahenobarbi/Gentoo-Recruiters-App/blob/master/lib/permissions/set.rb

def one_permission(permission, &block)
	define_method("#{permission.to_s}_permitted?", &block)
end

def multi_permission(*permission_list, &block)
	permission_list.flatten.each do |target|
		one_permission(target, &block)
	end
end

def permitted_for_roles(*roles)
  acting_user.signed_up? and roles.flatten.include?(acting_user.role.to_sym)
end