Class: Adva::Static::Import::Model::Site

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from Adva::Static::Import::Model::Base

Instance Method Details

#attribute_namesObject



18
19
20
# File 'lib/adva/static/import/model/site.rb', line 18

def attribute_names
  @attribute_names ||= (super | [:host, :name, :title]) - [:sections]
end

#recordObject



14
15
16
# File 'lib/adva/static/import/model/site.rb', line 14

def record
  @record ||= model.find_or_initialize_by_host(host)
end

#sectionsObject



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.first || Account.create
  super
  sections.each { |section| section.update! }
end