Class: Coupdoeil::Config
- Inherits:
-
Object
- Object
- Coupdoeil::Config
- Defined in:
- lib/coupdoeil/config.rb
Instance Attribute Summary collapse
-
#current ⇒ Coupdoeil::Config
Returns the current Coupdoeil::Config.
-
#default_dataset_format ⇒ Symbol
Default returned format of the coupdoeil_popover_dataset view helper.
-
#delegate_helper_methods ⇒ Boolean
Similarly to ‘include_all_helpers`, to offer a seamless experience when rendering popovers, Coupdoeil will delegate any helper methods defined on ApplicationController when this option is set to true.
-
#include_all_helpers ⇒ Boolean
Whether to load all application helpers so they are available when rendering a popover.
-
#options_html_attributes ⇒ Boolean
Whether to insert options as HTML attributes of the <coupdoeil> tag.
-
#validate_options ⇒ Boolean
Whether to validate popover options when building it.
Class Method Summary collapse
Instance Attribute Details
#current ⇒ Coupdoeil::Config
Returns the current Coupdoeil::Config. This is persisted against this class so that config options remain accessible before the rest of Coupdoeil has loaded. Defaults to an instance of Coupdoeil::Config with all other documented defaults set.
58 |
# File 'lib/coupdoeil/config.rb', line 58 class_attribute :current, default: defaults, instance_predicate: false |
#default_dataset_format ⇒ Symbol
Default returned format of the coupdoeil_popover_dataset view helper. See the helper documentation for available formats and their behavior. Defaults to ‘:html`.
|
|
# File 'lib/coupdoeil/config.rb', line 46
|
#delegate_helper_methods ⇒ Boolean
Similarly to ‘include_all_helpers`, to offer a seamless experience when rendering popovers, Coupdoeil will delegate any helper methods defined on ApplicationController when this option is set to true. Such helper methods could include `current_user` from Devise or `allowed_to?` from ActionPolicy, for example. As these helpers are not defined on modules like other helpers, they cannot be included and their call must therefore be delegated to the context controller. If this behavior causes unexpected behavior you can disable it with this configuration option, and/or [submit an issue](gitlab.com/Pagehey/coupdoeil/-/issues) so it can be investigated. However, in absence of problem, it is still recommended to let it `true` by default.
|
|
# File 'lib/coupdoeil/config.rb', line 36
|
#include_all_helpers ⇒ Boolean
Whether to load all application helpers so they are available when rendering a popover. This mimics the default behavior of Rails. It is advised to set it to true so that rendering popovers is seamless compared to rendering any other template. For all helpers to be included it is also required that ‘config.action_controller.include_all_helpers` is set to true.
|
|
# File 'lib/coupdoeil/config.rb', line 29
|
#options_html_attributes ⇒ Boolean
Whether to insert options as HTML attributes of the <coupdoeil> tag. This is not required for Coupdoeil to work since options are compressed to base 36 to lighten the HTML payload. This option is here to help for debug or testing. Defaults to ‘Rails.env.local?`.
|
|
# File 'lib/coupdoeil/config.rb', line 22
|
#validate_options ⇒ Boolean
Whether to validate popover options when building it. It will raise an error with a hint on how to fix it if an option’s value is not valid. Defaults to ‘Rails.env.local?`.
|
|
# File 'lib/coupdoeil/config.rb', line 16
|
Class Method Details
.defaults ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/coupdoeil/config.rb', line 6 def defaults ActiveSupport::OrderedOptions.new.merge!({ validate_options: Rails.env.local?, options_html_attributes: Rails.env.local?, include_all_helpers: true, delegate_helper_methods: true, default_dataset_format: :html, }) end |