Class: UltraSettings::ConfigurationView

Inherits:
Object
  • Object
show all
Includes:
RenderHelper
Defined in:
lib/ultra_settings/configuration_view.rb

Overview

This class can render information about a configuration in a clean card-based layout. It is used by the bundled web UI, but you can use it to embed the configuration information in your own web pages.

The output will be HTML with a card-based layout for better readability. The ‘table_class` option is still supported for backward compatibility but is no longer used in the new card layout.

Examples:

<h1>Service Configuration</h1>
<%= UltraSettings::ConfigurationView.new(ServiceConfiguration.instance).render %>

Instance Method Summary collapse

Methods included from RenderHelper

#html_escape, #render_partial

Constructor Details

#initialize(configuration) ⇒ ConfigurationView

Initialize the configuration view with a configuration instance.

Parameters:



19
20
21
# File 'lib/ultra_settings/configuration_view.rb', line 19

def initialize(configuration)
  @configuration = configuration
end

Instance Method Details

#render(table_class: "") ⇒ String

Render the HTML for the configuration view.

Parameters:

  • table_class (String) (defaults to: "")

    CSS class for the table element (maintained for backwards compatibility).

Returns:

  • (String)

    The rendered HTML.



27
28
29
30
31
32
# File 'lib/ultra_settings/configuration_view.rb', line 27

def render(table_class: "")
  configuration = @configuration
  html = ViewHelper.erb_template("configuration.html.erb").result(binding)
  html = html.html_safe if html.respond_to?(:html_safe)
  html
end

#to_sString

Convert the view to a string by rendering it.

Returns:

  • (String)

    The rendered HTML.



37
38
39
# File 'lib/ultra_settings/configuration_view.rb', line 37

def to_s
  render
end