Class: Adva::Static::Import::Model::Site
- Inherits:
-
Base
- Object
- Base
- Adva::Static::Import::Model::Site
show all
- Defined in:
- lib/adva/static/import/model/site.rb
Instance Attribute Summary
Attributes inherited from Base
#source
Instance Method Summary
collapse
Methods inherited from Base
#attribute?, #attribute_value, #attributes, #initialize, #model, #model_name, #updated_record
Instance Method Details
#attribute_names ⇒ Object
18
19
20
|
# File 'lib/adva/static/import/model/site.rb', line 18
def attribute_names
@attribute_names ||= (super | [:host, :name, :title]) - [:sections]
end
|
#record ⇒ Object
14
15
16
|
# File 'lib/adva/static/import/model/site.rb', line 14
def record
@record ||= model.find_or_initialize_by_host(host)
end
|
#sections ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/adva/static/import/model/site.rb', line 22
def sections
@sections ||= begin
sections = source.sections.map { |section| Model.build(section, self) }
sections << Page.new(source.path) if sections.empty?
sections
end
end
|
#update! ⇒ Object
8
9
10
11
12
|
# File 'lib/adva/static/import/model/site.rb', line 8
def update!
record.account = Account.first || Account.create
super
sections.each { |section| section.update! }
end
|