Class: Slugable::SlugBuilder::Flat

Inherits:
Object
  • Object
show all
Defined in:
lib/slugable/slug_builder/flat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Flat

Returns a new instance of Flat.



6
7
8
9
# File 'lib/slugable/slug_builder/flat.rb', line 6

def initialize(options)
  @slug_column = options.fetch(:slug_column)
  @formatter = options.fetch(:formatter)
end

Instance Attribute Details

#formatterObject (readonly)

Returns the value of attribute formatter.



4
5
6
# File 'lib/slugable/slug_builder/flat.rb', line 4

def formatter
  @formatter
end

#slug_columnObject (readonly)

Returns the value of attribute slug_column.



4
5
6
# File 'lib/slugable/slug_builder/flat.rb', line 4

def slug_column
  @slug_column
end

Instance Method Details

#to_slug(record) ⇒ Object



11
12
13
# File 'lib/slugable/slug_builder/flat.rb', line 11

def to_slug(record)
  record.public_send(slug_column)
end

#to_slug_was(record) ⇒ Object



15
16
17
# File 'lib/slugable/slug_builder/flat.rb', line 15

def to_slug_was(record)
  record.public_send(:"#{slug_column}_was")
end

#to_slug_will(record) ⇒ Object



19
20
21
# File 'lib/slugable/slug_builder/flat.rb', line 19

def to_slug_will(record)
  formatter.call(record.public_send(slug_column))
end