Class: Quickbooks::Model::BaseModel
- Inherits:
-
Object
- Object
- Quickbooks::Model::BaseModel
- Includes:
- ActiveModel::Validations, ROXML
- Defined in:
- lib/quickbooks/model/base_model.rb
Direct Known Subclasses
CustomField, Customer, CustomerRef, DiscountOverride, EmailAddress, Invoice, InvoiceItemRef, InvoiceLineItem, Item, LinkedTransaction, MetaData, PaymentLineDetail, PhysicalAddress, SalesItemLineDetail, SubTotalLineDetail, TelephoneNumber, WebSiteAddress
Class Method Summary collapse
-
.resource_for_collection ⇒ Object
These can be over-ridden in each model object as needed.
- .resource_for_singular ⇒ Object
Instance Method Summary collapse
-
#to_xml_inject_ns(model_name, options = {}) ⇒ Object
ROXML doesnt insert the namespaces into generated XML so we need to do it ourselves insert the static namespaces in the first opening tag that matches the
model_name. - #to_xml_ns(options = {}) ⇒ Object
Class Method Details
.resource_for_collection ⇒ Object
These can be over-ridden in each model object as needed
30 31 32 |
# File 'lib/quickbooks/model/base_model.rb', line 30 def resource_for_collection self::REST_RESOURCE end |
.resource_for_singular ⇒ Object
34 35 36 |
# File 'lib/quickbooks/model/base_model.rb', line 34 def resource_for_singular self::REST_RESOURCE end |
Instance Method Details
#to_xml_inject_ns(model_name, options = {}) ⇒ Object
ROXML doesnt insert the namespaces into generated XML so we need to do it ourselves
insert the static namespaces in the first opening tag that matches the model_name
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/quickbooks/model/base_model.rb', line 10 def to_xml_inject_ns(model_name, = {}) s = StringIO.new xml = to_xml().write_to(s, :indent => 0, :indent_text => '') destination_name = .fetch(:destination_name, nil) destination_name ||= model_name sparse = .fetch(:sparse, false) sparse_string = %{sparse="#{sparse}"} step1 = s.string.sub("<#{model_name}>", "<#{destination_name} #{Quickbooks::Service::BaseService::XML_NS} #{sparse_string}>") step2 = step1.sub("</#{model_name}>", "</#{destination_name}>") step2 end |
#to_xml_ns(options = {}) ⇒ Object
23 24 25 |
# File 'lib/quickbooks/model/base_model.rb', line 23 def to_xml_ns( = {}) to_xml_inject_ns(self.class::XML_NODE, ) end |