Class: SuperSettings::Configuration::Controller
- Inherits:
-
Object
- Object
- SuperSettings::Configuration::Controller
- Defined in:
- lib/super_settings/configuration.rb
Overview
Configuration for the controller.
Instance Attribute Summary collapse
-
#application_link ⇒ Object
Optional URL for a link back to the rest of the application.
-
#application_logo ⇒ Object
Optional mage URL for the application logo.
-
#application_name ⇒ Object
Optinal name of the application displayed in the view.
- #color_scheme ⇒ Object
- #enhancement ⇒ Object readonly private
- #superclass ⇒ Object
-
#web_ui_enabled ⇒ Object
writeonly
Enable or disable the web UI (the REST API will always be enabled).
Instance Method Summary collapse
-
#authentication_url=(value) ⇒ Object
Optional URL for a link to the login page for the application.
-
#changed_by(controller) ⇒ Object
private
Return the value of
define_changed_byblock. -
#define_changed_by { ... } ⇒ Object
Define how the
changed_byattibute on the setting history will be filled from the controller. -
#enhance { ... } ⇒ Object
Enhance the controller.
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
- #web_ui_enabled? ⇒ Boolean
-
#web_ui_javascript=(script) ⇒ Object
Javascript to inject into the settings application HTML page.
Constructor Details
#initialize ⇒ Controller
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 @application_logo = nil @application_link = nil end |
Instance Attribute Details
#application_link ⇒ Object
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_logo ⇒ Object
Optional mage URL for the application logo.
48 49 50 |
# File 'lib/super_settings/configuration.rb', line 48 def application_logo @application_logo end |
#application_name ⇒ Object
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_scheme ⇒ Object
75 76 77 |
# File 'lib/super_settings/configuration.rb', line 75 def color_scheme (@color_scheme ||= :light).to_sym end |
#enhancement ⇒ Object (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 |
#superclass ⇒ Object
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
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.
84 85 86 |
# File 'lib/super_settings/configuration.rb', line 84 def enhance(&block) @enhancement = block end |
#web_ui_enabled? ⇒ 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 |