Sha256: 4bd6279b223443d784396b8a09d5c1065cb18204ec56f1a55209b77a175d4892

Contents?: true

Size: 407 Bytes

Versions: 8

Compression:

Stored size: 407 Bytes

Contents

# frozen_string_literal: true

module EncodedId
  module Rails
    class SluggedIdParser
      def initialize(slugged_id, separator: "--")
        if separator && slugged_id.include?(separator)
          parts = slugged_id.split(separator)
          @slug = parts.first
          @id = parts.last
        else
          @id = slugged_id
        end
      end

      attr_reader :slug, :id
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
encoded_id-rails-1.0.0.beta3 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-1.0.0.beta2 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-1.0.0.beta1 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-0.6.2 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-0.6.1 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-0.6.0 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-0.5.0 lib/encoded_id/rails/slugged_id_parser.rb
encoded_id-rails-0.4.0 lib/encoded_id/rails/slugged_id_parser.rb