Class: Comable::Address

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/comable/address.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_or_clone(address) ⇒ Object


20
21
22
# File 'app/models/comable/address.rb', line 20

def find_or_clone(address)
  all.to_a.find { |obj| obj.same_as? address } || address.clone
end

Instance Method Details

#cloneObject


29
30
31
# File 'app/models/comable/address.rb', line 29

def clone
  self.class.new(contents)
end

#contentsObject


33
34
35
# File 'app/models/comable/address.rb', line 33

def contents
  attributes.except('id', 'user_id', 'created_at', 'updated_at')
end

#full_addressObject


41
42
43
# File 'app/models/comable/address.rb', line 41

def full_address
  "#{state_name} #{city} #{detail}"
end

#full_nameObject


37
38
39
# File 'app/models/comable/address.rb', line 37

def full_name
  "#{family_name} #{first_name}"
end

#same_as?(address) ⇒ Boolean

Returns:

  • (Boolean)

25
26
27
# File 'app/models/comable/address.rb', line 25

def same_as?(address)
  contents == address.contents
end