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
- #address_array ⇒ Object
- #address_hash ⇒ Object
- #address_pretty ⇒ Object
- #city ⇒ Object
- #city=(thing) ⇒ Object
- #state ⇒ Object
- #state=(thing) ⇒ Object
- #zip ⇒ Object
- #zip=(thing) ⇒ Object
- #zipcode ⇒ Object
- #zipcode=(thing) ⇒ Object
Instance Method Details
#address_array ⇒ Object
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_hash ⇒ Object
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_pretty ⇒ Object
36 37 38 |
# File 'lib/addressable.rb', line 36 def address_pretty stringify_array address_array end |
#city ⇒ Object
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 |
#state ⇒ Object
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 |
#zip ⇒ Object
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 |
#zipcode ⇒ Object
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 |