mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Pull out ident parsing from Epp::Contact class
This commit is contained in:
parent
043037225b
commit
bacdebd17c
3 changed files with 132 additions and 21 deletions
34
lib/deserializers/xml/ident.rb
Normal file
34
lib/deserializers/xml/ident.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue