Class: JGrouper::Member

Inherits:
Object
  • Object
show all
Defined in:
lib/jgrouper/member.rb

Overview

JGrouper::Member - Grouper Member

Usage

require 'jgrouper'

m = JGrouper::Member.find uuid

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj = nil) {|_self| ... } ⇒ Member

TODO

Yields:

  • (_self)

Yield Parameters:



15
16
17
18
19
# File 'lib/jgrouper/member.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 member object.



39
40
41
42
43
44
45
46
47
# File 'lib/jgrouper/member.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(uuid) {|member| ... } ⇒ Object

Find Grouper member by UUID. Returns JGrouper::Member or nil.

Yields:

  • (member)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jgrouper/member.rb', line 24

def self.find(uuid)
  begin
    m = JMemberFinder.find_by_uuid JGrouper.start_root_session, uuid, false
  rescue => e
    warn "JGrouper::Member.find(#{uuid}) => #{e}"
  end
  return nil if m.nil?
  member = self.new m
  yield member if block_given?
  member
end