Module: Stall::Addressable

Extended by:
ActiveSupport::Concern
Defined in:
lib/stall/addressable.rb

Instance Method Summary collapse

Instance Method Details

#billing_addressObject

Allow billing address to fall back to shipping address when not filled



25
26
27
28
# File 'lib/stall/addressable.rb', line 25

def billing_address
  association(:billing_address).load_target ||
    association(:shipping_address).load_target
end

#billing_address?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/stall/addressable.rb', line 30

def billing_address?
  billing_address.try(:persisted?) && billing_address.billing?
end

#shipping_addressObject

Allow shipping address to fall back to billing address when not filled



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

def shipping_address
  association(:shipping_address).load_target ||
    association(:billing_address).load_target
end

#shipping_address?Boolean

Returns:

  • (Boolean)


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

def shipping_address?
  shipping_address.try(:persisted?) && shipping_address.shipping?
end