29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/tentd/model/permissible.rb', line 29
def assign_permissions(permissions)
return unless permissions.kind_of?(Hash)
if permissions.groups && permissions.groups.kind_of?(Array)
permissions.groups.each do |g|
next unless g.id
group = Model::Group.first(:public_id => g.id, :fields => [:id])
self.permissions.create(:group => group) if group
end
end
if permissions.entities && permissions.entities.kind_of?(Hash)
permissions.entities.each do |entity,visible|
next unless visible
followers = Model::Follower.all(:entity => entity, :fields => [:id])
followers.each do |follower|
self.permissions.create(:follower_access => follower)
end
followings = Model::Following.all(:entity => entity, :fields => [:id])
followings.each do |following|
self.permissions.create(:following => following)
end
end
end
self.public = permissions.public unless permissions.public.nil?
end
|