Module: Addressable

Extended by:
ActiveSupport::Concern
Includes:
FieldsValidator
Included in:
MorseContactable
Defined in:
lib/addressable.rb

Constant Summary collapse

REQUIRED_DATABASE_FIELDS =
[:title, :address1, :address2, :address3, :town, :county, :country, :postcode]

Instance Method Summary collapse

Instance Method Details

#address_arrayObject



28
29
30
# File 'lib/addressable.rb', line 28

def address_array
  Array.new.tap { |a| REQUIRED_DATABASE_FIELDS.select { |key| a<<self.send(key) } }
end

#address_hashObject



32
33
34
# File 'lib/addressable.rb', line 32

def address_hash
  REQUIRED_DATABASE_FIELDS.each_with_object({}) { |f, o| o.merge!(f => self.send(f)) }
end

#address_prettyObject



36
37
38
# File 'lib/addressable.rb', line 36

def address_pretty
  stringify_array address_array
end

#cityObject



40
41
42
# File 'lib/addressable.rb', line 40

def city
  town
end

#city=(thing) ⇒ Object



44
45
46
# File 'lib/addressable.rb', line 44

def city=(thing)
  self.town = thing
end

#stateObject



48
49
50
# File 'lib/addressable.rb', line 48

def state
  county
end

#state=(thing) ⇒ Object



52
53
54
# File 'lib/addressable.rb', line 52

def state=(thing)
  self.county = thing
end

#zipObject



56
57
58
# File 'lib/addressable.rb', line 56

def zip
  postcode
end

#zip=(thing) ⇒ Object



60
61
62
# File 'lib/addressable.rb', line 60

def zip=(thing)
  self.postcode = thing
end

#zipcodeObject



64
65
66
# File 'lib/addressable.rb', line 64

def zipcode
  postcode
end

#zipcode=(thing) ⇒ Object



68
69
70
# File 'lib/addressable.rb', line 68

def zipcode=(thing)
  self.postcode = thing
end