Class: JGrouper::Field

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

Overview

JGrouper::Field - Grouper Group Field

Usage

require 'jgrouper'

TODO

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Field.

Yields:

  • (_self)

Yield Parameters:



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



31
32
33
34
35
36
37
38
39
# File 'lib/jgrouper/field.rb', line 31

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

.allObject

Find all fields.



24
25
26
# File 'lib/jgrouper/field.rb', line 24

def self.all
  JFieldFinder.find_all.collect { |_| self.new _ }
end

Instance Method Details

#to_hashObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jgrouper/field.rb', line 41

def to_hash
  {
    kind:             'field',
    group_type:       { name: @obj.get_group_type.get_name, uuid: @obj.get_group_type.get_uuid },
    name:             @obj.get_name,
    uuid:             @obj.get_uuid,
    nullable:         @obj.get_is_nullable,
    required:         @obj.get_required,
    read_privilege:   @obj.get_read_privilege,
    write_privilege:  @obj.get_write_privilege
  }
end

#to_jsonObject



54
55
56
# File 'lib/jgrouper/field.rb', line 54

def to_json
  to_hash.to_json
end