Class: Adva::Static::Import::Model::Section
- Inherits:
-
Base
- Object
- Base
- Adva::Static::Import::Model::Section
show all
- Defined in:
- lib/adva/static/import/model/section.rb
Instance Attribute Summary
Attributes inherited from Base
#source
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#<=>, #==, #attribute_name?, #attributes, #body, #column_name?, #initialize, #load, #model, #site_id, #updated_at, #updated_record
Class Method Details
.recognize(sources) ⇒ Object
11
12
13
|
# File 'lib/adva/static/import/model/section.rb', line 11
def recognize(sources)
types.map { |type| type.recognize(sources) }.flatten.compact.sort
end
|
.types ⇒ Object
7
8
9
|
# File 'lib/adva/static/import/model/section.rb', line 7
def types
[Blog, Page]
end
|
Instance Method Details
#attribute_names ⇒ Object
16
17
18
|
# File 'lib/adva/static/import/model/section.rb', line 16
def attribute_names
@attribute_names ||= [:site_id, :type, :name, :slug, :path]
end
|
#loadable ⇒ Object
44
45
46
|
# File 'lib/adva/static/import/model/section.rb', line 44
def loadable
@loadable ||= source.root? ? Source.new('index', source.root).find_or_self.full_path : source.full_path
end
|
#name ⇒ Object
32
33
34
|
# File 'lib/adva/static/import/model/section.rb', line 32
def name
@name ||= source.root? ? 'Home' : source.basename.titleize
end
|
#path ⇒ Object
40
41
42
|
# File 'lib/adva/static/import/model/section.rb', line 40
def path
@path ||= source.root? ? slug : super
end
|
#record ⇒ Object
20
21
22
|
# File 'lib/adva/static/import/model/section.rb', line 20
def record
@record ||= site.send(model.name.underscore.pluralize).find_or_initialize_by_path(path)
end
|
#site ⇒ Object
24
25
26
|
# File 'lib/adva/static/import/model/section.rb', line 24
def site
@site ||= Site.new(source.root).record
end
|
#slug ⇒ Object
36
37
38
|
# File 'lib/adva/static/import/model/section.rb', line 36
def slug
@slug ||= source.root? ? SimpleSlugs::Slug.new(name) : super
end
|
#type ⇒ Object
28
29
30
|
# File 'lib/adva/static/import/model/section.rb', line 28
def type
model.name
end
|