Class: ActiveSP::Role
- Extended by:
- Caching, PersistentCaching
- Defined in:
- lib/activesp/role.rb
Instance Method Summary collapse
-
#groups ⇒ Group
Returns the list of groups in this role.
-
#initialize(site, name) ⇒ Role
constructor
A new instance of Role.
-
#is_role? ⇒ Boolean
Returns true.
-
#key ⇒ String
See Base#key.
-
#save ⇒ void
See Base#save.
- #to_s ⇒ Object (also: #inspect)
-
#users ⇒ User
Returns the list of users in this role.
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
#groups ⇒ Group
Returns the list of groups in this role
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
70 71 72 |
# File 'lib/activesp/role.rb', line 70 def is_role? true end |
#key ⇒ String
See Base#key
43 44 45 |
# File 'lib/activesp/role.rb', line 43 def key encode_key("R", [@name]) end |
#save ⇒ void
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_s ⇒ Object Also known as: inspect
81 82 83 |
# File 'lib/activesp/role.rb', line 81 def to_s "#<ActiveSP::Role name=#{@name}>" end |
#users ⇒ User
Returns the list of users in this role
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 |