Module: Corzinus::AddressableAttrubutes
- Extended by:
- ActiveSupport::Concern
- Included in:
- Checkout::AddressStep, CheckoutsController
- Defined in:
- app/controllers/concerns/corzinus/addressable_attrubutes.rb
Instance Method Summary collapse
- #address_by_params(params) ⇒ Object
- #addresses_by_model(current_object) ⇒ Object
- #addresses_by_params(params, use_base_address = false) ⇒ Object
- #set_countries ⇒ Object
Instance Method Details
#address_by_params(params) ⇒ Object
29 30 31 |
# File 'app/controllers/concerns/corzinus/addressable_attrubutes.rb', line 29 def address_by_params(params) send("#{params[:address_type]}=", AddressForm.from_params(params)) end |
#addresses_by_model(current_object) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/controllers/concerns/corzinus/addressable_attrubutes.rb', line 9 def addresses_by_model(current_object) Address::TYPES.each do |type| address = current_object.send(type) form = AddressForm.from_model(address) .merge_info(current_object) send("#{type}=", form) end end |
#addresses_by_params(params, use_base_address = false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/concerns/corzinus/addressable_attrubutes.rb', line 18 def addresses_by_params(params, use_base_address = false) Address::TYPES.map do |type| form_params = params[:"#{type}_attributes"] if use_base_address form_params = params[:"#{Address::BASE}_attributes"] form_params[:address_type] = type end address_by_params(form_params) end end |
#set_countries ⇒ Object
33 34 35 |
# File 'app/controllers/concerns/corzinus/addressable_attrubutes.rb', line 33 def set_countries @countries = Country.select(:id, :name, :code) end |