Sha256: 83d5117b44816b40cf48d7d488b03b51937732e2abaa6557a0d42be3a107211a

Contents?: true

Size: 515 Bytes

Versions: 16

Compression:

Stored size: 515 Bytes

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    class Slug
      attr_reader :resource

      def initialize(resource)
        @resource = resource
      end

      def value
        self.class.build_from(resource.directory)
      end

      def self.build_from(chain)
        chain.map(&:parameterize).join('/')
      end

      def self.generate_resources_slugs
        Resource.tree.find_each do |res|
          res.update_columns slug: Slug.new(res).value
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/entities/lcms/engine/slug.rb
lcms-engine-0.5.4 app/entities/lcms/engine/slug.rb
lcms-engine-0.5.3 app/entities/lcms/engine/slug.rb
lcms-engine-0.5.2 app/entities/lcms/engine/slug.rb
lcms-engine-0.5.1 app/entities/lcms/engine/slug.rb
lcms-engine-0.5.0 app/entities/lcms/engine/slug.rb
lcms-engine-0.4.2 app/entities/lcms/engine/slug.rb
lcms-engine-0.4.1 app/entities/lcms/engine/slug.rb
lcms-engine-0.4.0 app/entities/lcms/engine/slug.rb
lcms-engine-0.3.1 app/entities/lcms/engine/slug.rb
lcms-engine-0.1.4 app/entities/lcms/engine/slug.rb
lcms-engine-0.3.0 app/entities/lcms/engine/slug.rb
lcms-engine-0.1.3 app/entities/lcms/engine/slug.rb
lcms-engine-0.2.0 app/entities/lcms/engine/slug.rb
lcms-engine-0.1.2 app/entities/lcms/engine/slug.rb
lcms-engine-0.1.0 app/entities/lcms/engine/slug.rb