Class: Lcms::Engine::Slug

Inherits:
Object
  • Object
show all
Defined in:
app/entities/lcms/engine/slug.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Slug

Returns a new instance of Slug.



8
9
10
# File 'app/entities/lcms/engine/slug.rb', line 8

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



6
7
8
# File 'app/entities/lcms/engine/slug.rb', line 6

def resource
  @resource
end

Class Method Details

.build_from(chain) ⇒ Object



16
17
18
# File 'app/entities/lcms/engine/slug.rb', line 16

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

.generate_resources_slugsObject



20
21
22
23
24
# File 'app/entities/lcms/engine/slug.rb', line 20

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

Instance Method Details

#valueObject



12
13
14
# File 'app/entities/lcms/engine/slug.rb', line 12

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