Class: Slugable::SlugBuilder::Flat
- Inherits:
-
Object
- Object
- Slugable::SlugBuilder::Flat
- Defined in:
- lib/slugable/slug_builder/flat.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#slug_column ⇒ Object
readonly
Returns the value of attribute slug_column.
Instance Method Summary collapse
-
#initialize(options) ⇒ Flat
constructor
A new instance of Flat.
- #to_slug(record) ⇒ Object
- #to_slug_was(record) ⇒ Object
- #to_slug_will(record) ⇒ Object
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() @slug_column = .fetch(:slug_column) @formatter = .fetch(:formatter) end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
4 5 6 |
# File 'lib/slugable/slug_builder/flat.rb', line 4 def formatter @formatter end |
#slug_column ⇒ Object (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 |