Pull out ident parsing from Epp::Contact class

This commit is contained in:
Maciej Szlosarczyk 2020-06-05 10:31:51 +03:00
parent 043037225b
commit bacdebd17c
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
3 changed files with 132 additions and 21 deletions

View file

@ -0,0 +1,34 @@
module Deserializers
module Xml
class Ident
attr_reader :frame
def initialize(frame)
@frame = frame.css('ident').first
end
def call
if valid?
{
ident: frame.text,
ident_type: frame.attr('type'),
ident_country_code: frame.attr('cc')
}
else
{}
end
end
private
def valid?
return false if frame.blank?
return false if frame.try('text').blank?
return false if frame.attr('type').blank?
return false if frame.attr('cc').blank?
true
end
end
end
end