Class: Map
Class Method Summary collapse
Instance Method Summary collapse
- #expanded_key_repository_path ⇒ Object
-
#grant(user_names, role_names, role_conditions = {}) ⇒ Object
This method has become too long again…
- #key_repository(repo = nil) ⇒ Object
- #namespace(&block) ⇒ Object
- #read! ⇒ Object
- #role(name, *hosts) ⇒ Object
- #user(*names) ⇒ Object
Class Method Details
Instance Method Details
#expanded_key_repository_path ⇒ Object
45 46 47 48 |
# File 'lib/fabric/map.rb', line 45 def File.join(Fabric.(:map_root), self.key_repository) # self.key_repository end |
#grant(user_names, role_names, role_conditions = {}) ⇒ Object
This method has become too long again…
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fabric/map.rb', line 67 def grant(user_names, role_names, role_conditions = {}) users = self.users.all roles = self.roles.all users = users.all(:name => user_names) unless user_names == :all roles = roles.all(:name => role_names) unless role_names == :all if role_conditions.include?(:except) roles = roles.all(:name.not => role_conditions[:except]) end if role_conditions.include?(:groups) role_conditions[:groups].each do |group| users.each do |user| user.groups.create(:name => group) end end end raise DataMapper::ObjectNotFoundError if users.empty? or roles.empty? roles.each do |role| role.users += users end end |
#key_repository(repo = nil) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/fabric/map.rb', line 37 def key_repository(repo = nil) if repo self.key_repository = repo end @key_repository end |
#namespace(&block) ⇒ Object
93 94 95 |
# File 'lib/fabric/map.rb', line 93 def namespace(&block) self.class.draw(:parent => self, &block) end |
#read! ⇒ Object
30 31 32 33 34 35 |
# File 'lib/fabric/map.rb', line 30 def read! self.roles.all.each do |role| role.update_user_access! end true end |
#role(name, *hosts) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/fabric/map.rb', line 50 def role(name, *hosts) role = self.roles.create(:name => name.to_s) hosts.each do |host| role.servers.create(:host => host) end role.save end |
#user(*names) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/fabric/map.rb', line 59 def user(*names) names.each do |name| user = self.users.create(:name => name.to_s) self.load_keys_from_repository(user) end end |