Class: BOSDK::InfoObject

Inherits:
Object
  • Object
show all
Defined in:
lib/bosdk/info_object.rb

Overview

Creates a wrapper around an IInfoObject.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (InfoObject) initialize(obj)

Creates a new InfoObject from the provided IInfoObject.

InfoObject.new(obj)


9
10
11
# File 'lib/bosdk/info_object.rb', line 9

def initialize(obj)
  @obj = obj
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args)

Forwards method to underlying IInfoObject and stores the results



40
41
42
43
44
45
46
# File 'lib/bosdk/info_object.rb', line 40

def method_missing(method, *args)
  eval "return @#{method.to_s}" if instance_variables.include?("@#{method.to_s}")
  if @obj.respond_to?(method)
    eval "return @#{method.to_s} = @obj.send(method, *args)"
  end
  super
end

Instance Attribute Details

- (Object) obj (readonly)

The underlying IInfoObject.



5
6
7
# File 'lib/bosdk/info_object.rb', line 5

def obj
  @obj
end

Instance Method Details

- (Object) <=>(other_infoobject)

Compares one InfoObject to another by #title.



35
36
37
# File 'lib/bosdk/info_object.rb', line 35

def <=>(other_infoobject)
  title <=> other_infoobject.title
end

- (Object) docid

Returns the Business Objects ID (alias for #getID).



14
15
16
# File 'lib/bosdk/info_object.rb', line 14

def docid
  getID
end

- (Boolean) is_root?

Returns true/false if #obj is a root node.



19
20
21
# File 'lib/bosdk/info_object.rb', line 19

def is_root?
  parent_id.nil? or parent_id == 0 or parent_id == docid
end

- (Object) parent

Returns the parent of #obj as an InfoObject



24
25
26
27
# File 'lib/bosdk/info_object.rb', line 24

def parent
  return nil if is_root?
  @parent ||= InfoObject.new(getParent)
end

- (Object) path

Returns the path of #obj as a String.



30
31
32
# File 'lib/bosdk/info_object.rb', line 30

def path
  @path ||= (is_root? ? '' : parent.path) + "/#{title}"
end

- (Boolean) respond_to?(method)

Returns true if underlying IInfoObject#respond_to? is true



49
50
51
# File 'lib/bosdk/info_object.rb', line 49

def respond_to?(method)
  @obj.respond_to?(method) || super
end