Sha256: 74c47bf9751abea95d4df3d3a6e99155b6d9e37c5099171b3ec69af26fdb5fa8
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module Comable class Address < ActiveRecord::Base belongs_to :customer, class_name: Comable::Customer.name, autosave: false validates :family_name, presence: true, length: { maximum: 255 } validates :first_name, presence: true, length: { maximum: 255 } validates :zip_code, presence: true, length: { maximum: 8 } validates :state_name, presence: true, length: { maximum: 255 } validates :city, presence: true, length: { maximum: 255 } validates :detail, length: { maximum: 255 } validates :phone_number, length: { maximum: 18 } class << self def find_or_clone(address) all.to_a.find { |obj| obj.same_as? address } || address.clone end end def same_as?(address) attributes_without_id == address.attributes_without_id end def clone self.class.new(attributes_without_id) end def attributes_without_id attributes.except('id', 'customer_id') end def full_name "#{family_name} #{first_name}" end def full_address "#{state_name} #{city} #{detail}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
comable_core-0.3.4 | app/models/comable/address.rb |
comable_core-0.3.3 | app/models/comable/address.rb |