Class: SuperSettings::Configuration::Controller

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

Overview

Configuration for the controller.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeController

Returns a new instance of Controller.



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

def initialize
  @superclass = nil
  @web_ui_enabled = true
  @color_scheme = false
  @changed_by_block = nil
  @enhancement = nil
  @application_name = nil
   = nil
  @application_link = nil
end

Instance Attribute Details

Optional URL for a link back to the rest of the application.



51
52
53
# File 'lib/super_settings/configuration.rb', line 51

def application_link
  @application_link
end

#application_logoObject

Optional mage URL for the application logo.



48
49
50
# File 'lib/super_settings/configuration.rb', line 48

def 
  
end

#application_nameObject

Optinal name of the application displayed in the view.



45
46
47
# File 'lib/super_settings/configuration.rb', line 45

def application_name
  @application_name
end

#color_schemeObject



75
76
77
# File 'lib/super_settings/configuration.rb', line 75

def color_scheme
  (@color_scheme ||= :light).to_sym
end

#enhancementObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/super_settings/configuration.rb', line 16

def enhancement
  @enhancement
end

#superclassObject



36
37
38
39
40
41
42
# File 'lib/super_settings/configuration.rb', line 36

def superclass
  if @superclass.is_a?(String)
    @superclass.constantize
  else
    @superclass
  end
end

#web_ui_enabled=(value) ⇒ Object (writeonly)

Enable or disable the web UI (the REST API will always be enabled).



65
66
67
# File 'lib/super_settings/configuration.rb', line 65

def web_ui_enabled=(value)
  @web_ui_enabled = value
end

Instance Method Details

#authentication_url=(value) ⇒ Object

Optional URL for a link to the login page for the application.



54
55
56
# File 'lib/super_settings/configuration.rb', line 54

def authentication_url=(value)
  SuperSettings.authentication_url = value
end

#changed_by(controller) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the value of define_changed_by block.



105
106
107
108
109
# File 'lib/super_settings/configuration.rb', line 105

def changed_by(controller)
  if @changed_by_block
    controller.instance_eval(&@changed_by_block)
  end
end

#define_changed_by { ... } ⇒ Object

Define how the changed_by attibute on the setting history will be filled from the controller. The block will be evaluated in the context of the controller when the settings are changed. The value returned by the block will be stored in the changed_by attribute. For example, if your base controller class defines a method current_user and you’d like the name to be stored in the history, you could call

Examples:

define_changed_by { current_user.name }

Yields:

  • Block of code to call on the controller at request time



98
99
100
# File 'lib/super_settings/configuration.rb', line 98

def define_changed_by(&block)
  @changed_by_block = block
end

#enhance { ... } ⇒ Object

Enhance the controller. You can define methods or call controller class methods like before_action, etc. in the block. These will be applied to the engine controller. This is essentially the same a monkeypatching the controller class.

Yields:

  • Block of code to inject into the controller class.



84
85
86
# File 'lib/super_settings/configuration.rb', line 84

def enhance(&block)
  @enhancement = block
end

#web_ui_enabled?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/super_settings/configuration.rb', line 67

def web_ui_enabled?
  !!@web_ui_enabled
end

#web_ui_javascript=(script) ⇒ Object

Javascript to inject into the settings application HTML page. This can be used, for example, to set authorization credentials stored client side to access the settings API.



60
61
62
# File 'lib/super_settings/configuration.rb', line 60

def web_ui_javascript=(script)
  SuperSettings.web_ui_javascript = script
end