Class: Slimak::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#columnObject

Returns the value of attribute column.



11
12
13
# File 'lib/slimak/configuration.rb', line 11

def column
  @column
end

#conflict_strategyObject

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_lengthObject

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

#scopeObject

Returns the value of attribute scope.



11
12
13
# File 'lib/slimak/configuration.rb', line 11

def scope
  @scope
end

#separatorObject

Returns the value of attribute separator.



11
12
13
# File 'lib/slimak/configuration.rb', line 11

def separator
  @separator
end

#sequence_separatorObject

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_limitsObject

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_hashObject

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