Class: Bukovina::Importers::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/bukovina/importers/name.rb

Instance Method Summary collapse

Instance Method Details

#find_or_init(in_attrs) ⇒ Object



3
4
5
6
# File 'lib/bukovina/importers/name.rb', line 3

def find_or_init in_attrs
attrs = in_attrs.deep_dup
attrs.delete(:bind_kind)
::Name.where( attrs ).first || init( in_attrs ) ; end

#importObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bukovina/importers/name.rb', line 11

def import
      @attrs.map do |attrs|
# find name
bond_to = attrs.delete( :bond_to )
r = find_or_init( attrs )

if bond_to
   s = bond_to.deep_dup
   s.delete( :bond_to )
   bond_to = Name.where( s ).first
   r.bond_to = bond_to ; end

begin
r.save!
rescue
   binding.pry
   raise $!
end
r ;end;end

#init(attrs) ⇒ Object



8
9
# File 'lib/bukovina/importers/name.rb', line 8

def init attrs
Name.new( attrs ) ;end