Class: SolidLog::UI::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/solid_log/ui/configuration.rb', line 15

def initialize
  # Mode: :direct_db (same database) or :http_api (remote service)
  @mode = :direct_db

  # HTTP API mode settings
  @service_url = nil
  @service_token = nil

  # Direct DB mode settings
  @database_path = nil

  # Controller inheritance - defaults to ActionController::Base
  # Set to "ApplicationController" or your app's base controller
  @base_controller = "ActionController::Base"

  # UI settings
  # Authentication: :none, :basic, or a Proc/Symbol/String
  # - :none - no authentication required
  # - :basic - HTTP basic authentication (uses authenticate_with_basic_auth)
  # - Proc/Lambda - custom authentication logic (called in controller context)
  # - Symbol/String - method name to call on the controller
  @authentication_method = :none
  @websocket_enabled = true
  @stream_view_style = :compact  # :compact or :expanded
  @facet_cache_ttl = 1.minute
  @per_page = 100
end

Instance Attribute Details

#authentication_method ⇒ Object

Returns the value of attribute authentication_method.



13
14
15
# File 'lib/solid_log/ui/configuration.rb', line 13

def authentication_method
  @authentication_method
end

#base_controller ⇒ Object

Returns the value of attribute base_controller.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def base_controller
  @base_controller
end

#database_path ⇒ Object

Returns the value of attribute database_path.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def database_path
  @database_path
end

#facet_cache_ttl ⇒ Object

Returns the value of attribute facet_cache_ttl.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def facet_cache_ttl
  @facet_cache_ttl
end

#mode ⇒ Object

Returns the value of attribute mode.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def mode
  @mode
end

#per_page ⇒ Object

Returns the value of attribute per_page.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def per_page
  @per_page
end

#service_token ⇒ Object

Returns the value of attribute service_token.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def service_token
  @service_token
end

#service_url ⇒ Object

Returns the value of attribute service_url.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def service_url
  @service_url
end

#stream_view_style ⇒ Object

Returns the value of attribute stream_view_style.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def stream_view_style
  @stream_view_style
end

#websocket_enabled ⇒ Object

Returns the value of attribute websocket_enabled.



4
5
6
# File 'lib/solid_log/ui/configuration.rb', line 4

def websocket_enabled
  @websocket_enabled
end

Instance Method Details

#authentication_method_name? ⇒ Boolean

Check if authentication is a method name

Returns:

  • (Boolean)


63
64
65
# File 'lib/solid_log/ui/configuration.rb', line 63

def authentication_method_name?
  authentication_method.is_a?(Symbol) && ![:none, :basic].include?(authentication_method)
end

#authentication_proc? ⇒ Boolean

Check if authentication is a proc

Returns:

  • (Boolean)


58
59
60
# File 'lib/solid_log/ui/configuration.rb', line 58

def authentication_proc?
  authentication_method.is_a?(Proc)
end

#direct_db_mode? ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/solid_log/ui/configuration.rb', line 90

def direct_db_mode?
  mode == :direct_db
end

#http_api_mode? ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/solid_log/ui/configuration.rb', line 94

def http_api_mode?
  mode == :http_api
end

#valid? ⇒ Boolean

Validate configuration

Returns:

  • (Boolean)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/solid_log/ui/configuration.rb', line 68

def valid?
  errors = []

  case mode
  when :direct_db
    # Direct DB mode doesn't require additional config (uses core's connection)
  when :http_api
    errors << "service_url required for http_api mode" if service_url.blank?
    errors << "service_token required for http_api mode" if service_token.blank?
  else
    errors << "mode must be :direct_db or :http_api"
  end

  # Authentication validation is handled by the setter

  if errors.any?
    raise ArgumentError, "Invalid UI configuration:\n  #{errors.join("\n  ")}"
  end

  true
end