Class: Location::AddressPersister

Inherits:
Object
  • Object
show all
Defined in:
app/models/location/address_persister.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(normalizer, address) ⇒ AddressPersister

Returns a new instance of AddressPersister.



5
6
7
8
# File 'app/models/location/address_persister.rb', line 5

def initialize(normalizer, address)
  @normalizer = normalizer
  @address = address
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



3
4
5
# File 'app/models/location/address_persister.rb', line 3

def address
  @address
end

#normalizerObject (readonly)

Returns the value of attribute normalizer.



3
4
5
# File 'app/models/location/address_persister.rb', line 3

def normalizer
  @normalizer
end

Instance Method Details

#persist!Object



10
11
12
13
14
15
16
17
18
# File 'app/models/location/address_persister.rb', line 10

def persist!
  State.transaction(requires_new: true) do
    if @address && @address.persisted?
      update
    else
      create
    end
  end
end