class UserGroupModel
The model has the following structure in the repo:
user/ : FsModelItemClass user/$NAME/ : FsModelItem user/$NAME/id : Property user/$NAME/full_name : Property user/$NAME/created : Property group/ : FsModelItemClass group/$NAME/ : FsModelItem group/$NAME/id : Property group/$NAME/owner : ProxyProperty group/$NAME/users : ProxyItemList
Public Class Methods
new(db)
click to toggle source
Calls superclass method
GitDS::Model::new
# File doc/examples/user_group/model.rb, line 73 def initialize(db) super db, 'user/group model' end
Public Instance Methods
add_group(name, id, owner_name)
click to toggle source
Add a Group to the model.
# File doc/examples/user_group/model.rb, line 102 def add_group(name, id, owner_name) owner = user(owner_name) args = { :name => name, :id => id.to_i, :owner => owner } GroupModelItem.new self, GroupModelItem.create(self.root, args) end
add_user(name, id, fullname='')
click to toggle source
Add a User to the model.
# File doc/examples/user_group/model.rb, line 80 def add_user(name, id, fullname='') args = {:username => name, :id => id.to_i, :fullname => fullname } UserModelItem.new self, UserModelItem.create(self.root, args) end
group(ident)
click to toggle source
Instantiate a Group object by name.
# File doc/examples/user_group/model.rb, line 119 def group(ident) GroupModelItem.new self, GroupModelItem.instance_path(self.root.path, ident) end
groups()
click to toggle source
List the names of all Groups in the model.
# File doc/examples/user_group/model.rb, line 112 def groups GroupModelItem.list(self.root) end
user(ident)
click to toggle source
Instantiate a User object based on the username.
# File doc/examples/user_group/model.rb, line 95 def user(ident) UserModelItem.new self, UserModelItem.instance_path(self.root.path, ident) end
users()
click to toggle source
Return a list of the usernames of all Users in the model
# File doc/examples/user_group/model.rb, line 88 def users UserModelItem.list(self.root) end