Module: SAXMachine
- Included in:
- Pepper::Stanzas::AccountAddr, Pepper::Stanzas::AccountInfdata, Pepper::Stanzas::Chkdata, Pepper::Stanzas::ContactInfdata, Pepper::Stanzas::DomainInfdata, Pepper::Stanzas::Epp, Pepper::Stanzas::Host, Pepper::Stanzas::Ns, Pepper::Stanzas::Resdata, Pepper::Stanzas::Response, Pepper::Stanzas::Result
- Defined in:
- lib/pepper/stanzas/sax_machinery.rb
Overview
Mixup the mixin - to add functionality for simplifying results down to a hash
Instance Method Summary collapse
Instance Method Details
#to_hash ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pepper/stanzas/sax_machinery.rb', line 5 def to_hash convert = Proc.new {|v| if v.methods.include? "to_hash" v.to_hash elsif v.is_a? Array v.map {|e| convert.call e } else v end } instance_variables.inject({}) do |h,v| h.merge v.gsub("@","") => convert.call( instance_variable_get v ) end end |