class Sluggable::Rails::Definitions

Public Class Methods

new() click to toggle source
# File lib/sluggable/rails/definitions.rb, line 4
def initialize
  @definitions = {}
end

Public Instance Methods

[](attribute) click to toggle source
# File lib/sluggable/rails/definitions.rb, line 8
def [](attribute)
  @definitions[attribute.to_s.to_sym]
end
add(attribute = :slug, origin:, separator: '-', scope: nil) click to toggle source
# File lib/sluggable/rails/definitions.rb, line 12
def add(attribute = :slug, origin:, separator: '-', scope: nil)
  @definitions[attribute.to_s.to_sym] = Sluggable::Rails::Definition.new attribute, origin: origin, separator: separator, scope: scope
end
each(&block) click to toggle source
# File lib/sluggable/rails/definitions.rb, line 22
def each(&block)
  @definitions.each &block
end
slugs(from:) click to toggle source
# File lib/sluggable/rails/definitions.rb, line 16
def slugs(from:)
  slugs = Sluggable::Rails::Slugs.new
  @definitions.each { |_, definition| slugs.add definition, from }
  slugs
end