Class: Dscf::Marketplace::Retailer::Registration
- Inherits:
-
Object
- Object
- Dscf::Marketplace::Retailer::Registration
- Includes:
- Core::RoleAssignable
- Defined in:
- app/models/dscf/marketplace/retailer/registration.rb
Defined Under Namespace
Classes: InvalidInput
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#retailer ⇒ Object
readonly
Returns the value of attribute retailer.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #create! ⇒ Object
-
#initialize(user_attributes:, retailer_attributes:, address_attributes: {}, actor: nil, obsolete_profile_address: false) ⇒ Registration
constructor
A new instance of Registration.
Constructor Details
#initialize(user_attributes:, retailer_attributes:, address_attributes: {}, actor: nil, obsolete_profile_address: false) ⇒ Registration
Returns a new instance of Registration.
18 19 20 21 22 23 24 25 |
# File 'app/models/dscf/marketplace/retailer/registration.rb', line 18 def initialize(user_attributes:, retailer_attributes:, address_attributes: {}, actor: nil, obsolete_profile_address: false) @user_attributes = user_attributes.to_h.deep_symbolize_keys @retailer_attributes = retailer_attributes.to_h.deep_symbolize_keys @address_attributes = address_attributes.to_h.deep_symbolize_keys @actor = actor @obsolete_profile_address = obsolete_profile_address end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
16 17 18 |
# File 'app/models/dscf/marketplace/retailer/registration.rb', line 16 def address @address end |
#retailer ⇒ Object (readonly)
Returns the value of attribute retailer.
16 17 18 |
# File 'app/models/dscf/marketplace/retailer/registration.rb', line 16 def retailer @retailer end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
16 17 18 |
# File 'app/models/dscf/marketplace/retailer/registration.rb', line 16 def user @user end |
Instance Method Details
#create! ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/dscf/marketplace/retailer/registration.rb', line 27 def create! validate_obsolete_profile_address! validate_phone! coordinates = registration_coordinates categories = preferred_categories ActiveRecord::Base.transaction do @user = Dscf::Core::User.create!(@user_attributes) assign_default_role(@user, "RETAILER") @retailer = create_retailer!(coordinates) @address = create_address!(coordinates) @retailer.preferred_categories = categories end self end |