Class: WellsFargo::Element
- Inherits:
-
Object
- Object
- WellsFargo::Element
- Defined in:
- lib/wells_fargo/element.rb,
lib/wells_fargo/elements/file.rb,
lib/wells_fargo/elements/name.rb,
lib/wells_fargo/elements/note.rb,
lib/wells_fargo/elements/check.rb,
lib/wells_fargo/elements/eff_dt.rb,
lib/wells_fargo/elements/bank_id.rb,
lib/wells_fargo/elements/cur_amt.rb,
lib/wells_fargo/elements/id_info.rb,
lib/wells_fargo/elements/message.rb,
lib/wells_fargo/elements/payroll.rb,
lib/wells_fargo/elements/pmt_rec.rb,
lib/wells_fargo/elements/po_info.rb,
lib/wells_fargo/elements/ra_info.rb,
lib/wells_fargo/elements/delivery.rb,
lib/wells_fargo/elements/earnings.rb,
lib/wells_fargo/elements/file_out.rb,
lib/wells_fargo/elements/ref_info.rb,
lib/wells_fargo/elements/tax_info.rb,
lib/wells_fargo/elements/amt_group.rb,
lib/wells_fargo/elements/bank_info.rb,
lib/wells_fargo/elements/date_info.rb,
lib/wells_fargo/elements/phone_num.rb,
lib/wells_fargo/elements/post_addr.rb,
lib/wells_fargo/elements/deductions.rb,
lib/wells_fargo/elements/exemptions.rb,
lib/wells_fargo/elements/pmt_detail.rb,
lib/wells_fargo/elements/rcvr_party.rb,
lib/wells_fargo/elements/dep_acct_id.rb,
lib/wells_fargo/elements/invoice_adj.rb,
lib/wells_fargo/elements/invoice_mgr.rb,
lib/wells_fargo/elements/orgnr_party.rb,
lib/wells_fargo/elements/contact_info.rb,
lib/wells_fargo/elements/doc_delivery.rb,
lib/wells_fargo/elements/invoice_info.rb,
lib/wells_fargo/elements/pmt_supp_ccr.rb,
lib/wells_fargo/elements/pmt_supp_fdm.rb,
lib/wells_fargo/elements/pmt_supp_pob.rb,
lib/wells_fargo/elements/pmt_supp_wtx.rb,
lib/wells_fargo/elements/return_party.rb,
lib/wells_fargo/elements/vendor_party.rb,
lib/wells_fargo/elements/edd_biller_id.rb,
lib/wells_fargo/elements/file_info_grp.rb,
lib/wells_fargo/elements/delivery_party.rb,
lib/wells_fargo/elements/earnings_total.rb,
lib/wells_fargo/elements/deductions_total.rb,
lib/wells_fargo/elements/rcvr_dep_acct_id.rb,
lib/wells_fargo/elements/account_reporting.rb,
lib/wells_fargo/elements/orgnr_dep_acct_id.rb,
lib/wells_fargo/elements/additional_details.rb,
lib/wells_fargo/elements/intermediary_dep_acct_id.rb
Direct Known Subclasses
AccountReporting, AdditionalDetails, AmtGroup, BankID, BankInfo, Check, ContactInfo, CurAmt, DateInfo, Deductions, DeductionsTotal, Delivery, DeliveryParty, DepAcctID, DocDelivery, EDDBillerID, Earnings, EarningsTotal, EffDt, Exemptions, File, FileInfoGrp, FileOut, IDInfo, IntermediaryDepAcctID, InvoiceAdj, InvoiceInfo, InvoiceMgr, Message, Name, Note, OrgnrDepAcctID, OrgnrParty, POInfo, Payroll, PhoneNum, PmtDetail, PmtRec, PmtSuppCCR, PmtSuppFDM, PmtSuppPOB, PmtSuppWTX, PostAddr, RAInfo, RcvrDepAcctID, RcvrParty, RefInfo, ReturnParty, TaxInfo, VendorParty
Defined Under Namespace
Classes: AccountReporting, AdditionalDetails, AmtGroup, BankID, BankInfo, Check, ContactInfo, CurAmt, DateInfo, Deductions, DeductionsTotal, Delivery, DeliveryParty, DepAcctID, DocDelivery, EDDBillerID, Earnings, EarningsTotal, EffDt, Exemptions, File, FileInfoGrp, FileOut, IDInfo, IntermediaryDepAcctID, InvoiceAdj, InvoiceInfo, InvoiceMgr, Message, Name, Note, OrgnrDepAcctID, OrgnrParty, POInfo, Payroll, PhoneNum, PmtDetail, PmtRec, PmtSuppCCR, PmtSuppFDM, PmtSuppPOB, PmtSuppWTX, PostAddr, RAInfo, RcvrDepAcctID, RcvrParty, RefInfo, ReturnParty, TaxInfo, VendorParty
Constant Summary collapse
- NameMap =
Schema.NameMap
Class Attribute Summary collapse
-
.attributes ⇒ Object
Returns the value of attribute attributes.
-
.children ⇒ Object
Returns the value of attribute children.
-
.required ⇒ Object
Returns the value of attribute required.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#xml ⇒ Object
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
- #add_child(name, attributes = {}, &block) ⇒ Object
- #element_name ⇒ Object
-
#initialize(xml, attributes) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(xml, attributes) ⇒ Element
Returns a new instance of Element.
8 9 10 11 |
# File 'lib/wells_fargo/element.rb', line 8 def initialize xml, attributes @xml = xml @attributes = attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
46 47 48 49 50 51 52 |
# File 'lib/wells_fargo/element.rb', line 46 def method_missing method, *args, &block if self.class.children.any? {|c| method.to_sym == c[:name] } add_child method, *args, &block else super end end |
Class Attribute Details
.attributes ⇒ Object
Returns the value of attribute attributes.
56 57 58 |
# File 'lib/wells_fargo/element.rb', line 56 def attributes @attributes end |
.children ⇒ Object
Returns the value of attribute children.
56 57 58 |
# File 'lib/wells_fargo/element.rb', line 56 def children @children end |
.required ⇒ Object
Returns the value of attribute required.
56 57 58 |
# File 'lib/wells_fargo/element.rb', line 56 def required @required end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/wells_fargo/element.rb', line 4 def attributes @attributes end |
#xml ⇒ Object
Returns the value of attribute xml.
4 5 6 |
# File 'lib/wells_fargo/element.rb', line 4 def xml @xml end |
Class Method Details
.attribute(name) ⇒ Object
57 58 59 60 |
# File 'lib/wells_fargo/element.rb', line 57 def attribute name @attributes ||= [] @attributes << name end |
.child(name, limit = nil) ⇒ Object
68 69 70 71 |
# File 'lib/wells_fargo/element.rb', line 68 def child name, limit = nil @children ||= [] @children << {:name => name, :limit => limit} end |
.required_attribute(name) ⇒ Object
62 63 64 65 66 |
# File 'lib/wells_fargo/element.rb', line 62 def required_attribute name @required ||= [] @required << name attribute name end |
Instance Method Details
#add_child(name, attributes = {}, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wells_fargo/element.rb', line 13 def add_child name, attributes = {}, &block child_class_name = NameMap[name.to_s] child_class = retrieve_element_class child_class_name child = child_class.new(xml, attributes) capture = proc do |x| if block_given? content = yield child content.to_s elsif !attributes.is_a?(Hash) attributes.to_s end end if child.attributes.is_a?(Hash) xml.tag! child.element_name, child.attributes, &capture else xml.tag! child.element_name, child.attributes end end |
#element_name ⇒ Object
35 36 37 |
# File 'lib/wells_fargo/element.rb', line 35 def element_name self.class.name.split('::').last end |