Class: ActiveSP::Role

Inherits:
Base
  • Object
show all
Extended by:
Caching, PersistentCaching
Includes:
InSite, Util
Defined in:
lib/activesp/role.rb

Instance Method Summary collapse

Methods included from Caching

extended

Methods inherited from Base

#attribute, #attribute_type, #attribute_types, #attributes, #has_attribute?, #has_writable_attribute?, #method_missing, #reload, #set_attribute

Constructor Details

#initialize(site, name) ⇒ Role

Returns a new instance of Role.



37
38
39
# File 'lib/activesp/role.rb', line 37

def initialize(site, name)
  @site, @name = site, name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveSP::Base

Instance Method Details

#groupsGroup

Returns the list of groups in this role

Returns:



59
60
61
62
63
64
# File 'lib/activesp/role.rb', line 59

def groups
  call("UserGroup", "get_group_collection_from_role", "roleName" => @name).xpath("//spdir:Group", NS).map do |row|
    attributes = clean_attributes(row.attributes)
    Group.new(@site, attributes["Name"])
  end
end

#is_role?Boolean

Returns true. The same method is present on Group where it returns false. Roles and groups can generally be duck-typed, and this method is there for the rare case where you do need to make the distinction

Returns:

  • (Boolean)


70
71
72
# File 'lib/activesp/role.rb', line 70

def is_role?
  true
end

#keyString

See Base#key

Returns:

  • (String)


43
44
45
# File 'lib/activesp/role.rb', line 43

def key
  encode_key("R", [@name])
end

#savevoid

This method returns an undefined value.

See Base#save



76
77
78
# File 'lib/activesp/role.rb', line 76

def save
  p untype_cast_attributes(@site, nil, internal_attribute_types, changed_attributes)
end

#to_sObject Also known as: inspect



81
82
83
# File 'lib/activesp/role.rb', line 81

def to_s
  "#<ActiveSP::Role name=#{@name}>"
end

#usersUser

Returns the list of users in this role

Returns:



49
50
51
52
53
54
# File 'lib/activesp/role.rb', line 49

def users
  call("UserGroup", "get_user_collection_from_role", "roleName" => @name).xpath("//spdir:User", NS).map do |row|
    attributes = clean_attributes(row.attributes)
    User.new(@site, attributes["LoginName"])
  end
end