Module: OwnerLoginMode

Overview

typed: ignore frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#current_ownerObject Also known as: current_user



4
5
6
7
8
9
10
11
12
# File 'app/my_lib/owner_login_mode.rb', line 4

def current_owner
  @current_owner ||= if dashboard_v2_owner_signed_in?
                       OwnerDecorator.decorate(current_dashboard_v2_owner)
                     elsif dashboard_v2_staff_signed_in?
                       StaffDecorator.decorate current_dashboard_v2_staff
                     elsif dashboard_v2_restaurant_group_signed_in?
                       RestaurantGroupDecorator.decorate(current_dashboard_v2_restaurant_group)
                     end
end

#group_owner_type?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
# File 'app/my_lib/owner_login_mode.rb', line 15

def group_owner_type?
  return true if request_path_contain_group? && dashboard_v2_restaurant_group_signed_in?

  if dashboard_v2_staff_signed_in?
    return true if current_dashboard_v2_staff.restaurants.count > 1
  end
  false
end

#request_path_contain_group?Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'app/my_lib/owner_login_mode.rb', line 34

def request_path_contain_group?
  # return true if request.path is match with "/group"
  request.path.to_s.match?(/group/)
end

#single_owner_type?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
# File 'app/my_lib/owner_login_mode.rb', line 24

def single_owner_type?
  return true if !request_path_contain_group? && dashboard_v2_owner_signed_in?

  if dashboard_v2_staff_signed_in?
    return true if current_dashboard_v2_staff.restaurants.count == 1
  end

  false
end