Class: Ronin::DB::StreetAddress
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ronin::DB::StreetAddress
- Includes:
- Model
- Defined in:
- lib/ronin/db/street_address.rb
Overview
Represents a street address.
Instance Attribute Summary collapse
-
#address ⇒ String
The address number and street name.
-
#city ⇒ String
The city name.
-
#country ⇒ String
The country name.
-
#created_at ⇒ Time
Tracks when the street address was first created.
-
#id ⇒ Integer
The primary key of the street address.
-
#notes ⇒ Array<Note>
The associated notes.
-
#organization_departments ⇒ Array<OrganizationDepartment>
The organization departments located at the street address.
-
#organization_street_addresses ⇒ Array<OrganizationStreetAddress>
The association of organizations that associate with the street address.
-
#people ⇒ Array<Organization>
The people that are associated with the street addresses.
-
#personal_street_addresses ⇒ Array<PersonalStreetAddress>
The association of people that associate with the street address.
-
#state ⇒ String?
The state or province name.
-
#zipcode ⇒ String?
The zipcode or postal code.
Class Method Summary collapse
-
.for_organization(name) ⇒ Array<StreetAddress>
Queries all street addresses associated with an organization's name.
-
.for_person(full_name) ⇒ Array<StreetAddress>
Queries all street addresses associated with the person's full name.
-
.with_address(address) ⇒ Array<StreetAddress>
Queries all street addresses with the matching address.
-
.with_city(city) ⇒ Array<StreetAddress>
Queries all street addresses with the matching city.
-
.with_country(country) ⇒ Array<StreetAddress>
Queries all street addresses with the matching country.
-
.with_province(province) ⇒ Object
Alias for StreetAddress.with_state.
-
.with_state(state) ⇒ Array<StreetAddress>
Queries all street addresses with the matching state.
-
.with_zipcode(zipcode) ⇒ Array<StreetAddress>
Queries all street addresses with the matching zipcode.
Instance Method Summary collapse
-
#postal_code ⇒ String?
Alias for #zipcode.
-
#postal_code=(new_postal_code) ⇒ String?
Alias for #zipcode=.
-
#province ⇒ String?
Alias for #state.
-
#province=(new_province) ⇒ String?
Alias for #state=.
-
#to_s ⇒ String
Converts the street address to a String.
Methods included from Model
Instance Attribute Details
#address ⇒ String
The address number and street name.
46 |
# File 'lib/ronin/db/street_address.rb', line 46 attribute :address, :string |
#city ⇒ String
The city name.
62 |
# File 'lib/ronin/db/street_address.rb', line 62 attribute :city, :string |
#country ⇒ String
The country name.
96 |
# File 'lib/ronin/db/street_address.rb', line 96 attribute :country, :string |
#created_at ⇒ Time
Tracks when the street address was first created.
108 |
# File 'lib/ronin/db/street_address.rb', line 108 attribute :created_at, :datetime |
#id ⇒ Integer
The primary key of the street address.
40 |
# File 'lib/ronin/db/street_address.rb', line 40 attribute :id, :integer |
#notes ⇒ Array<Note>
The associated notes.
126 |
# File 'lib/ronin/db/street_address.rb', line 126 has_many :notes |
#organization_departments ⇒ Array<OrganizationDepartment>
The organization departments located at the street address.
139 |
# File 'lib/ronin/db/street_address.rb', line 139 has_many :organization_departments, dependent: :nullify |
#organization_street_addresses ⇒ Array<OrganizationStreetAddress>
The association of organizations that associate with the street address.
133 |
# File 'lib/ronin/db/street_address.rb', line 133 has_many :organization_street_addresses, dependent: :destroy |
#people ⇒ Array<Organization>
The people that are associated with the street addresses.
120 |
# File 'lib/ronin/db/street_address.rb', line 120 has_many :people, through: :personal_street_addresses |
#personal_street_addresses ⇒ Array<PersonalStreetAddress>
The association of people that associate with the street address.
114 |
# File 'lib/ronin/db/street_address.rb', line 114 has_many :personal_street_addresses, dependent: :destroy |
#state ⇒ String?
The state or province name.
74 |
# File 'lib/ronin/db/street_address.rb', line 74 attribute :state, :string |
#zipcode ⇒ String?
The zipcode or postal code.
85 |
# File 'lib/ronin/db/street_address.rb', line 85 attribute :zipcode, :string |
Class Method Details
.for_organization(name) ⇒ Array<StreetAddress>
Queries all street addresses associated with an organization's name.
167 168 169 170 171 172 173 |
# File 'lib/ronin/db/street_address.rb', line 167 def self.for_organization(name) joins(organization_street_addresses: :organization).where( organization_street_addresses: { ronin_organizations: {name: name} } ) end |
.for_person(full_name) ⇒ Array<StreetAddress>
Queries all street addresses associated with the person's full name.
152 153 154 |
# File 'lib/ronin/db/street_address.rb', line 152 def self.for_person(full_name) joins(:people).where(people: {full_name: full_name}) end |
.with_address(address) ⇒ Array<StreetAddress>
Queries all street addresses with the matching address.
186 187 188 |
# File 'lib/ronin/db/street_address.rb', line 186 def self.with_address(address) where(address: address) end |
.with_city(city) ⇒ Array<StreetAddress>
Queries all street addresses with the matching city.
201 202 203 |
# File 'lib/ronin/db/street_address.rb', line 201 def self.with_city(city) where(city: city) end |
.with_country(country) ⇒ Array<StreetAddress>
Queries all street addresses with the matching country.
242 243 244 |
# File 'lib/ronin/db/street_address.rb', line 242 def self.with_country(country) where(country: country) end |
.with_province(province) ⇒ Object
Alias for with_state.
227 228 229 |
# File 'lib/ronin/db/street_address.rb', line 227 def self.with_province(province) with_state(province) end |
.with_state(state) ⇒ Array<StreetAddress>
Queries all street addresses with the matching state.
216 217 218 |
# File 'lib/ronin/db/street_address.rb', line 216 def self.with_state(state) where(state: state) end |
.with_zipcode(zipcode) ⇒ Array<StreetAddress>
Queries all street addresses with the matching zipcode.
257 258 259 |
# File 'lib/ronin/db/street_address.rb', line 257 def self.with_zipcode(zipcode) where(zipcode: zipcode) end |
Instance Method Details
#postal_code ⇒ String?
Alias for #zipcode.
299 300 301 |
# File 'lib/ronin/db/street_address.rb', line 299 def postal_code zipcode end |
#postal_code=(new_postal_code) ⇒ String?
Alias for #zipcode=.
315 316 317 |
# File 'lib/ronin/db/street_address.rb', line 315 def postal_code=(new_postal_code) self.zipcode = new_postal_code end |
#province ⇒ String?
Alias for #state.
270 271 272 |
# File 'lib/ronin/db/street_address.rb', line 270 def province state end |
#province=(new_province) ⇒ String?
Alias for #state=.
286 287 288 |
# File 'lib/ronin/db/street_address.rb', line 286 def province=(new_province) self.state = new_province end |
#to_s ⇒ String
Converts the street address to a String.
324 325 326 327 328 329 330 |
# File 'lib/ronin/db/street_address.rb', line 324 def to_s string = "#{address}#{$/}#{city}" string << ", #{state}" if state string << " #{zipcode}" if zipcode string << "#{$/}#{country}" return string end |