Class: Quickbooks::Type

Inherits:
Object show all
Defined in:
lib/quickbooks/type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil) ⇒ Type

Returns a new instance of Type.

Raises:

  • (RuntimeError)


19
20
21
22
23
# File 'lib/quickbooks/type.rb', line 19

def initialize(value=nil)
  raise RuntimeError, "Type class '#{self.class.short_name}' has no native class set. This is a BUG. Please report it!" unless self.class.native.is_a?(Module)
  self.value = value
  clean!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (private)



69
70
71
72
73
# File 'lib/quickbooks/type.rb', line 69

def method_missing(method_name, *args, &block)
  block_given? ?
    @value.method(method_name).call(*args) {|*arr| yield *arr } :
    @value.method(method_name).call(*args)
end

Instance Attribute Details

#valueObject Also known as: __value__

Returns the value of attribute value.



13
14
15
# File 'lib/quickbooks/type.rb', line 13

def value
  @value
end

Class Method Details

.native(type = nil) ⇒ Object



5
6
7
8
# File 'lib/quickbooks/type.rb', line 5

def native(type=nil)
  @native = type if type
  @native
end

Instance Method Details

#dirty?Boolean

Returns:



38
39
40
# File 'lib/quickbooks/type.rb', line 38

def dirty?
  @dirty || @value != @original_value
end

#eql?(value) ⇒ Boolean Also known as: ===

Returns:



25
26
27
# File 'lib/quickbooks/type.rb', line 25

def eql?(value)
  @value.eql?(value)
end

#inspectObject



46
47
48
# File 'lib/quickbooks/type.rb', line 46

def inspect
  $DEBUG ? super : @value.inspect
end

#nil?Boolean

Returns:



30
31
32
# File 'lib/quickbooks/type.rb', line 30

def nil?
  @value.nil?
end

#to_sObject



34
35
36
# File 'lib/quickbooks/type.rb', line 34

def to_s
  @value.to_s
end

#to_xmlObject



50
51
52
# File 'lib/quickbooks/type.rb', line 50

def to_xml
  @value.to_s.xml_escaped
end

#valid?Boolean

Returns:



42
43
44
# File 'lib/quickbooks/type.rb', line 42

def valid?
  raise "Not Implemented Yet! (Type Validation)"
end