Class: Slimak::Configuration
- Inherits:
-
Object
- Object
- Slimak::Configuration
- Defined in:
- lib/slimak/configuration.rb
Overview
Global configuration object for Slimak. Configure in an initializer or test with: Slimak.configure do |config|
config.separator = "_"
config.conflict_strategy = :random
config.random_suffix_length = 6
config.slug_column_limits = { name: 10 }
end
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#conflict_strategy ⇒ Object
Returns the value of attribute conflict_strategy.
-
#random_suffix_length ⇒ Object
Returns the value of attribute random_suffix_length.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#separator ⇒ Object
Returns the value of attribute separator.
-
#sequence_separator ⇒ Object
Returns the value of attribute sequence_separator.
-
#slug_column_limits ⇒ Object
Returns the value of attribute slug_column_limits.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#to_hash ⇒ Object
Convert config to a plain hash used by Sluggable defaults.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 26 27 |
# File 'lib/slimak/configuration.rb', line 19 def initialize @column = :slug @separator = "-" @conflict_strategy = :sequence @sequence_separator = "-" @random_suffix_length = 4 @scope = nil @slug_column_limits = {} end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def column @column end |
#conflict_strategy ⇒ Object
Returns the value of attribute conflict_strategy.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def conflict_strategy @conflict_strategy end |
#random_suffix_length ⇒ Object
Returns the value of attribute random_suffix_length.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def random_suffix_length @random_suffix_length end |
#scope ⇒ Object
Returns the value of attribute scope.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def scope @scope end |
#separator ⇒ Object
Returns the value of attribute separator.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def separator @separator end |
#sequence_separator ⇒ Object
Returns the value of attribute sequence_separator.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def sequence_separator @sequence_separator end |
#slug_column_limits ⇒ Object
Returns the value of attribute slug_column_limits.
11 12 13 |
# File 'lib/slimak/configuration.rb', line 11 def slug_column_limits @slug_column_limits end |
Instance Method Details
#to_hash ⇒ Object
Convert config to a plain hash used by Sluggable defaults
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/slimak/configuration.rb', line 30 def to_hash { column: @column, separator: @separator, conflict_strategy: @conflict_strategy, sequence_separator: @sequence_separator, random_suffix_length: @random_suffix_length, scope: @scope } end |