Skip to content

Commit

Permalink
Streamline deprecation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
aldesantis committed May 11, 2020
1 parent 2abbf81 commit 49347c3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions core/app/models/concerns/spree/user_address_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,29 @@ def mark_default(user_address, address_type: :shipping)
end

def default_address
Spree::Deprecation.warn "This association is deprecated. Please start using ship_address = address"
Spree::Deprecation.warn "#default_address is deprecated. Please start using #ship_address."
ship_address
end

def default_user_address
Spree::Deprecation.warn "This association is deprecated. Please start using #default_user_ship_address."
Spree::Deprecation.warn "#default_user_address is deprecated. Please start using #default_user_ship_address."
default_user_ship_address
end

def default_address=(address)
Spree::Deprecation.warn "This setter does not take into account Spree::Config.automatic_default_address and is deprecated. "\
"Please start using ship_address = address"
Spree::Deprecation.warn(
"#default_address= does not take Spree::Config.automatic_default_address into account and is deprecated. " \
"Please use #ship_address=."
)

self.ship_address = address if address
end

def default_address_attributes=(attributes)
# see "Nested Attributes Examples" section of http://apidock.com/rails/ActionView/Helpers/FormHelper/fields_for
# this #{fieldname}_attributes= method works with fields_for in the views
# even without declaring accepts_nested_attributes_for
Spree::Deprecation.warn "This setter is deprecated. Please start using ship_address_attributes = attributes"
Spree::Deprecation.warn "This setter is deprecated. Please use #ship_address_attributes=."

self.default_address = Spree::Address.immutable_merge(ship_address, attributes)
end
Expand Down Expand Up @@ -155,8 +158,10 @@ def save_in_address_book(address_attributes, default = false, address_type = :sh
end

def mark_default_address(address)
Spree::Deprecation.warn "This method is deprecated and it sets the ship_address only. " \
"Please start using #mark_default_ship_address for that"
Spree::Deprecation.warn(
"#mark_default_address is deprecated and it sets the ship_address only. " \
"Please use #mark_default_ship_address."
)

mark_default_ship_address(address)
end
Expand Down

0 comments on commit 49347c3

Please sign in to comment.