Class: Location::AddressForm

Inherits:
Object
  • Object
show all
Includes:
AddressNormalizable, AddressValidatable, SuperForm
Defined in:
app/models/location/address_form.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AddressNormalizable

#address_normalizer, #normalizable_address_attributes=

Instance Attribute Details

#addressObject

Returns the value of attribute address.



31
32
33
# File 'app/models/location/address_form.rb', line 31

def address
  @address
end

Class Method Details

.default_presence_attributesObject



12
13
14
# File 'app/models/location/address_form.rb', line 12

def self.default_presence_attributes
  %i{postal_code street district}
end

.float_attributesObject



20
21
22
# File 'app/models/location/address_form.rb', line 20

def self.float_attributes
  %i{latitude longitude}
end

.string_attributesObject



16
17
18
# File 'app/models/location/address_form.rb', line 16

def self.string_attributes
  %i{postal_code street number complement district city state}
end

Instance Method Details

#presenceObject



33
34
35
# File 'app/models/location/address_form.rb', line 33

def presence
  @presence || validate_presence_of(AddressForm.default_presence_attributes)
end

#validate_presence_of(attributes) ⇒ Object



37
38
39
40
41
42
43
44
# File 'app/models/location/address_form.rb', line 37

def validate_presence_of(attributes)
  attributes = Array(attributes)

  @presence = self.attributes.keys.inject({}) do |hash, attr|
    hash[attr] = attributes.include?(attr)
    hash
  end
end