Module: Sem4rSoap::SoapAttributes
- Included in:
- Sem4r::AdGroupBids, Sem4r::AdGroupCriterion, Sem4r::AdGroupCriterionBids, Sem4r::Address, Sem4r::Base, Sem4r::BillingAddress, Sem4r::BulkMutateJob, Sem4r::BulkMutateJobSelector, Sem4r::CountryTargetSearchParameter, Sem4r::ExcludedKeywordSearchParameter, Sem4r::GeoLocationSelector, Sem4r::InfoSelector, Sem4r::KeywordMatchTypeSearchParameter, Sem4r::NgramGroupsSearchParameter, Sem4r::Operation, Sem4r::RelatedToKeywordSearchParameter, Sem4r::ReportField, Sem4r::TIdeaTypeAttribute, Sem4r::TKeywordAttribute, Sem4r::TMonthlySearchVolumeAttribute, Sem4r::TargetingIdea, Sem4r::TargetingIdeaSelector
- Defined in:
- lib/sem4r_soap/soap_attributes.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
45 46 47 |
# File 'lib/sem4r_soap/soap_attributes.rb', line 45 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#_from_element(el) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/sem4r_soap/soap_attributes.rb', line 61 def _from_element(el) self.class.attributes.each do |a| unless a.enum? value = el.at_xpath(a.xpath) __send__ a.name, value.text.strip unless value.nil? end end self end |
#_to_s ⇒ Object
71 72 73 74 75 |
# File 'lib/sem4r_soap/soap_attributes.rb', line 71 def _to_s self.class.attributes.map do |a| if a.enum? then "" else self.send(a.name) end end.join(' ') end |
#_to_xml(tag) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sem4r_soap/soap_attributes.rb', line 49 def _to_xml(tag) builder = Builder::XmlMarkup.new builder.tag!(tag) do |t| self.class.attributes.each do |a| unless a.enum? value = self.send(a.name) t.__send__(a.xpath, value) unless value.nil? # value could be a boolean so 'if value' is wrong end end end end |