Class: Coupdoeil::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/coupdoeil/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#currentCoupdoeil::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.

Returns:



51
# File 'lib/coupdoeil/config.rb', line 51

class_attribute :current, default: defaults, instance_predicate: false

#delegate_helper_methodsBoolean

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.

Returns:

  • (Boolean)


# File 'lib/coupdoeil/config.rb', line 35

#include_all_helpersBoolean

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.

Returns:

  • (Boolean)


# File 'lib/coupdoeil/config.rb', line 28

#options_html_attributesBoolean

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?`.

Returns:

  • (Boolean)


# File 'lib/coupdoeil/config.rb', line 21

#validate_optionsBoolean

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?`.

Returns:

  • (Boolean)


# File 'lib/coupdoeil/config.rb', line 15

Class Method Details

.defaultsObject



6
7
8
9
10
11
12
13
# 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,
  })
end