Class: Quickbooks::Property
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value = nil) ⇒ Property
Returns a new instance of Property.
28
29
30
31
|
# File 'lib/quickbooks/property.rb', line 28
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?(Class)
@value = value.is_a?(self.class.native) ? value : self.class.native.new(value)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/quickbooks/property.rb', line 56
def method_missing(method_name, *args, &block)
if block_given?
if @value.respond_to?(method_name)
@value.method(method_name).call(*args) {|*arr| yield *arr }
else
args << block
@value.send(method_name, *args)
end
else
@value.send(method_name, *args)
end
end
|
Class Attribute Details
Returns the value of attribute xsd.
13
14
15
|
# File 'lib/quickbooks/property.rb', line 13
def xsd
@xsd
end
|
Instance Attribute Details
#value ⇒ Object
Also known as:
__value__
Returns the value of attribute value.
22
23
24
|
# File 'lib/quickbooks/property.rb', line 22
def value
@value
end
|
Class Method Details
15
16
17
|
# File 'lib/quickbooks/property.rb', line 15
def native
@native ||= Quickbooks::Types.const_get(xsd.type.name)
end
|
Instance Method Details
#eql?(value) ⇒ Boolean
Also known as:
===
33
34
35
|
# File 'lib/quickbooks/property.rb', line 33
def eql?(value)
@value.eql?(value)
end
|
42
43
44
|
# File 'lib/quickbooks/property.rb', line 42
def inspect
"#{self.class.short_name}[#{@value.class.short_name.gsub(/type$/,'')}]=#{@value.inspect}"
end
|
38
39
40
|
# File 'lib/quickbooks/property.rb', line 38
def nil?
@value.nil?
end
|
#to_dirty_xml(include_required = false) ⇒ Object
52
53
54
|
# File 'lib/quickbooks/property.rb', line 52
def to_dirty_xml(include_required=false)
to_xml
end
|
46
47
48
|
# File 'lib/quickbooks/property.rb', line 46
def to_s
@value.to_s
end
|
49
50
51
|
# File 'lib/quickbooks/property.rb', line 49
def to_xml
'<' + self.class.short_name + '>' + @value.to_xml + '</' + self.class.short_name + '>'
end
|