Class: ProductTours::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/product_tours/configuration.rb

Constant Summary collapse

DEFAULT_ADMIN_LAYOUT =

The gem's own dashboard layout. Compared against, so DashboardController can tell "the host left this alone" from "the host chose this".

'product_tours/application'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
# File 'lib/product_tours/configuration.rb', line 27

def initialize
  @enabled = ->(_request) { true }
  @authorize_admin = ->(_request) { Rails.env.development? }
  @admin_layout = DEFAULT_ADMIN_LAYOUT
  @base_controller_class = 'ActionController::Base'
  @mount_path = '/product_tours'
  @storage_service = nil
end

Instance Attribute Details

#admin_layoutObject

Returns the value of attribute admin_layout.



9
10
11
# File 'lib/product_tours/configuration.rb', line 9

def admin_layout
  @admin_layout
end

#authorize_adminObject

Returns the value of attribute authorize_admin.



9
10
11
# File 'lib/product_tours/configuration.rb', line 9

def authorize_admin
  @authorize_admin
end

#base_controller_classObject

The controller the DASHBOARD inherits from, as a String so it resolves lazily rather than at config time. Default: a plain 'ActionController::Base', where authorize_admin is the only gate.

Name the controller your own admin already inherits from and the dashboard adopts that whole stack — layout, helpers, authentication, and any request context your before_actions set up. admin_layout covers only the layout, which leaves a host layout calling its own helpers to raise NameError under the engine's isolated namespace.

Only the dashboard uses it. The widget's endpoints stay on the engine's own public controller, so an admin base controller here can never demand a staff session from a visitor being shown a tour.



25
26
27
# File 'lib/product_tours/configuration.rb', line 25

def base_controller_class
  @base_controller_class
end

#enabledObject

Returns the value of attribute enabled.



9
10
11
# File 'lib/product_tours/configuration.rb', line 9

def enabled
  @enabled
end

#mount_pathObject

Returns the value of attribute mount_path.



9
10
11
# File 'lib/product_tours/configuration.rb', line 9

def mount_path
  @mount_path
end

#storage_serviceObject

Returns the value of attribute storage_service.



9
10
11
# File 'lib/product_tours/configuration.rb', line 9

def storage_service
  @storage_service
end

Instance Method Details

#widget_endpointObject



36
# File 'lib/product_tours/configuration.rb', line 36

def widget_endpoint = "#{mount_path.to_s.chomp('/')}/widget"