zoho_invoice 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/zoho_invoice/base.rb +2 -2
- data/lib/zoho_invoice/version.rb +1 -1
- data/spec/zoho_invoice/base_spec.rb +6 -6
- metadata +1 -1
data/lib/zoho_invoice/base.rb
CHANGED
@@ -65,7 +65,7 @@ module ZohoInvoice
|
|
65
65
|
self.reflections.each { |r| self.send("#{r}=", []) }
|
66
66
|
(self.reflections & options.keys).each do |reflection|
|
67
67
|
options[reflection].each do |reflection_obj|
|
68
|
-
klass =
|
68
|
+
klass = ZohoInvoice.const_get(camel_case(reflection.to_s[0..-2]))
|
69
69
|
if reflection_obj.is_a?(Hash)
|
70
70
|
self.send("#{reflection}") << klass.new(@client, reflection_obj)
|
71
71
|
elsif reflection_obj.is_a?(klass)
|
@@ -149,7 +149,7 @@ module ZohoInvoice
|
|
149
149
|
|
150
150
|
def build_attributes
|
151
151
|
Nokogiri::XML::Builder.new do |xml|
|
152
|
-
xml.send("#{self.class}") {
|
152
|
+
xml.send("#{self.class.to_s.split('::').last}") {
|
153
153
|
self.attributes.each do |attr|
|
154
154
|
vals = self.send(attr)
|
155
155
|
if !vals.nil? && !vals.is_a?(Array)
|
data/lib/zoho_invoice/version.rb
CHANGED
@@ -38,7 +38,7 @@ describe ZohoInvoice::Base do
|
|
38
38
|
|
39
39
|
describe "generating an xml representation" do
|
40
40
|
before do
|
41
|
-
class Something < ZohoInvoice::Base
|
41
|
+
class ZohoInvoice::Something < ZohoInvoice::Base
|
42
42
|
define_object_attrs :test_it,
|
43
43
|
:blah,
|
44
44
|
:something_id
|
@@ -47,7 +47,7 @@ describe ZohoInvoice::Base do
|
|
47
47
|
:more_things
|
48
48
|
end
|
49
49
|
|
50
|
-
@test_obj = Something.new(@client)
|
50
|
+
@test_obj = ZohoInvoice::Something.new(@client)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should specific an xml doctype" do
|
@@ -206,10 +206,10 @@ describe ZohoInvoice::Base do
|
|
206
206
|
end
|
207
207
|
|
208
208
|
describe "nested associations" do
|
209
|
-
class Tuna < ZohoInvoice::Base
|
209
|
+
class ZohoInvoice::Tuna < ZohoInvoice::Base
|
210
210
|
define_object_attrs :blah
|
211
211
|
end
|
212
|
-
class TestIt < ZohoInvoice::Base
|
212
|
+
class ZohoInvoice::TestIt < ZohoInvoice::Base
|
213
213
|
has_many :tunas
|
214
214
|
end
|
215
215
|
|
@@ -218,14 +218,14 @@ describe ZohoInvoice::Base do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it "can be created at initialization" do
|
221
|
-
test = TestIt.new(@client, :tunas => [{:blah => 1234}, Tuna.new(@client, :blah => 5678)])
|
221
|
+
test = ZohoInvoice::TestIt.new(@client, :tunas => [{:blah => 1234}, ZohoInvoice::Tuna.new(@client, :blah => 5678)])
|
222
222
|
expect(test.tunas.length).to eq(2)
|
223
223
|
expect(test.tunas.first.blah).to eq(1234)
|
224
224
|
expect(test.tunas.last.blah).to eq(5678)
|
225
225
|
end
|
226
226
|
|
227
227
|
it "outputted when coverted to xml", :focus => true do
|
228
|
-
test = TestIt.new(@client, :tunas => [{:blah => 1234}])
|
228
|
+
test = ZohoInvoice::TestIt.new(@client, :tunas => [{:blah => 1234}])
|
229
229
|
doc = Nokogiri::XML(test.to_xml)
|
230
230
|
expect(doc.xpath('//Tunas').length).to be >= 1
|
231
231
|
expect(doc.xpath('//Tuna').length).to eq(1)
|