Class: Acts::Permalink::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



6
7
8
9
10
11
12
13
14
15
# File 'lib/config.rb', line 6

def initialize(options={})
  @config = options.with_indifferent_access

  @to = @config[:to].try(:to_sym) || :permalink
  @from = @config[:from].try(:to_sym) || :title
  @separator = @config[:underscore] ? "_" : "-"

  @max_length = @config[:max_length].to_i rescue 0
  @max_length = 60 unless @max_length > 0
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



4
5
6
# File 'lib/config.rb', line 4

def from
  @from
end

#max_lengthObject (readonly)

Returns the value of attribute max_length.



4
5
6
# File 'lib/config.rb', line 4

def max_length
  @max_length
end

#separatorObject (readonly)

Returns the value of attribute separator.



4
5
6
# File 'lib/config.rb', line 4

def separator
  @separator
end

#toObject (readonly)

Returns the value of attribute to.



4
5
6
# File 'lib/config.rb', line 4

def to
  @to
end