Class: StaffService::TemporaryAccess
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- StaffService::TemporaryAccess
- Includes:
- DefaultErrorContainer
- Defined in:
- app/services/staff_service/temporary_access.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#expired_at ⇒ Object
readonly
Returns the value of attribute expired_at.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#restaurant_ids ⇒ Object
readonly
Returns the value of attribute restaurant_ids.
-
#staff ⇒ Object
readonly
Returns the value of attribute staff.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(restaurant_ids, account = nil) ⇒ TemporaryAccess
constructor
A new instance of TemporaryAccess.
- #result ⇒ Object
- #success? ⇒ Boolean
Methods included from DefaultErrorContainer
#error, #error_message_simple, #merge_errors
Constructor Details
#initialize(restaurant_ids, account = nil) ⇒ TemporaryAccess
Returns a new instance of TemporaryAccess.
5 6 7 8 |
# File 'app/services/staff_service/temporary_access.rb', line 5 def initialize(restaurant_ids, account = nil) @restaurant_ids = Array(restaurant_ids) # Ensure it's always an array @account = account end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
3 4 5 |
# File 'app/services/staff_service/temporary_access.rb', line 3 def account @account end |
#expired_at ⇒ Object (readonly)
Returns the value of attribute expired_at.
3 4 5 |
# File 'app/services/staff_service/temporary_access.rb', line 3 def expired_at @expired_at end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
3 4 5 |
# File 'app/services/staff_service/temporary_access.rb', line 3 def password @password end |
#restaurant_ids ⇒ Object (readonly)
Returns the value of attribute restaurant_ids.
3 4 5 |
# File 'app/services/staff_service/temporary_access.rb', line 3 def restaurant_ids @restaurant_ids end |
#staff ⇒ Object (readonly)
Returns the value of attribute staff.
3 4 5 |
# File 'app/services/staff_service/temporary_access.rb', line 3 def staff @staff end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/services/staff_service/temporary_access.rb', line 10 def call return false unless valid? create_temporary_staff create_staff_roles send_credentials_email schedule_deletion end |
#result ⇒ Object
19 20 21 |
# File 'app/services/staff_service/temporary_access.rb', line 19 def result { email: staff.email, password: password, expired_at: expired_at, auto_login_url: auto_login_url } end |
#success? ⇒ Boolean
23 24 25 |
# File 'app/services/staff_service/temporary_access.rb', line 23 def success? errors.blank? end |