76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/allows.rb', line 76
def set_permissions
if (!@permissions && @allows) || (defined?(RAILS_ENV) && RAILS_ENV == 'development')
@permissions = Hash.new
if @allows
@allows.each do |p|
allowed = Hash.new
hash = p.select{|o| o.is_a?(Hash)}
allowed[:permissions] = p - hash
actions = hash.first
if hash.first
allowed[:except] = actions[:except]
allowed[:only] = actions[:only]
end
if allowed[:only] allowed_actions = Array(allowed[:only])
elsif allowed[:except] allowed_actions = controller_actions - Array(allowed[:except])
else allowed_actions = controller_actions
end
allowed_actions.each do |action|
@permissions[action.to_sym] = (Array(@permissions[action.to_sym]) + allowed[:permissions]).uniq
end
end
end
end
end
|