Class: JGrouper::Privilege
- Inherits:
-
Object
- Object
- JGrouper::Privilege
show all
- Defined in:
- lib/jgrouper/privilege.rb
Overview
JGrouper::Privilege - Grouper Privilee
Usage
require 'jgrouper'
priv = JGrouper::Privilege.find name
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(obj = nil) {|_self| ... } ⇒ Privilege
15
16
17
18
19
|
# File 'lib/jgrouper/privilege.rb', line 15
def initialize( obj = nil )
@obj = obj
yield self if block_given?
self
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
For passing methods on to Grouper subject object.
39
40
41
42
43
44
45
46
47
|
# File 'lib/jgrouper/privilege.rb', line 39
def method_missing(meth, *args, &block)
super if @obj.nil?
begin
block.call @obj.send(meth, *args) if block
@obj.send(meth, *args)
rescue NoMethodError
super
end
end
|
Class Method Details
.find(name) {|privilege| ... } ⇒ Object
Find Grouper privilege by name. Returns JGrouper::Privilege
or nil
.
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/jgrouper/privilege.rb', line 24
def self.find(name)
begin
priv = JPrivilege.getInstance name
rescue => e
warn "JGrouper::Privilege.find(#{name}) => #{e}"
end
return nil if priv.nil?
privilege = self.new priv
yield privilege if block_given?
privilege
end
|
Instance Method Details
#access? ⇒ Boolean
49
|
# File 'lib/jgrouper/privilege.rb', line 49
def access?; JPrivilege.isAccess(@obj); end
|
#naming? ⇒ Boolean
50
|
# File 'lib/jgrouper/privilege.rb', line 50
def naming?; JPrivilege.isNaming(@obj); end
|
#to_grouper ⇒ Object
53
|
# File 'lib/jgrouper/privilege.rb', line 53
def to_grouper; @obj; end
|
#to_s ⇒ Object
55
56
57
58
|
# File 'lib/jgrouper/privilege.rb', line 55
def to_s
return nil if @obj.nil?
%w( name type ).collect { |k| "#{k}=#{ self.send(k) }" }.to_csv.chomp
end
|
#type ⇒ Object
51
|
# File 'lib/jgrouper/privilege.rb', line 51
def type; access? ? :access : :naming; end
|