Class: Filterameter::Configuration

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

Overview

# Configuration

Class Configuration stores the following settings:

  • action_on_undeclared_parameters

  • action_on_validation_failure

  • filter_key

## Action on Undeclared Parameters

Occurs when the filter parameter contains any keys that are not defined. Valid actions are :log, :raise, and false (do not take action). By default, development will log, test will raise, and production will do nothing.

## Action on Validation Failure

Occurs when a filter parameter fails a validation. Valid actions are :log, :raise, and false (do not take action). By default, development will log, test will raise, and production will do nothing.

## Filter Key

By default, the filter parameters are nested under the key :filter. Use this setting to override the key.

If the filter parameters are NOT nested, set this to false. Doing so will restrict the filter parameters to only those that have been declared, meaning undeclared parameters are ignored (and the action_on_undeclared_parameters configuration option does not come into play).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/filterameter/configuration.rb', line 35

def initialize
  @action_on_undeclared_parameters =
    @action_on_validation_failure =
      if Rails.env.development?
        :log
      elsif Rails.env.test?
        :raise
      else
        false
      end

  @filter_key = :filter
end

Instance Attribute Details

#action_on_undeclared_parametersObject

Returns the value of attribute action_on_undeclared_parameters.



33
34
35
# File 'lib/filterameter/configuration.rb', line 33

def action_on_undeclared_parameters
  @action_on_undeclared_parameters
end

#action_on_validation_failureObject

Returns the value of attribute action_on_validation_failure.



33
34
35
# File 'lib/filterameter/configuration.rb', line 33

def action_on_validation_failure
  @action_on_validation_failure
end

#filter_keyObject

Returns the value of attribute filter_key.



33
34
35
# File 'lib/filterameter/configuration.rb', line 33

def filter_key
  @filter_key
end