Class: Adva::Static::Import::Model::Page

Inherits:
Section
  • Object
show all
Defined in:
lib/adva/static/import/model/page.rb

Constant Summary collapse

PATTERN =
%r([\w-]+\.(#{Source::TYPES.join('|')})$)

Instance Attribute Summary

Attributes inherited from Base

#source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Section

#loadable, #name, #path, #record, #site, #slug, #type, types

Methods inherited from Base

#<=>, #==, #attribute_name?, #attributes, #body, #column_name?, #initialize, #load, #loadable, #model, #path, #site_id, #slug, #updated_at, #updated_record

Constructor Details

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

Class Method Details

.recognize(sources) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/adva/static/import/model/page.rb', line 9

def recognize(sources)
  return [] if sources.blank?

  pages = sources.select { |source| source.to_s =~ PATTERN }
  sources.replace(sources - pages)

  pages = pages.map { |source| source.self_and_parents.map(&:find_or_self) }.flatten.uniq
  pages = pages.map { |source| new(source) }
  pages
end

Instance Method Details

#attribute_namesObject



21
22
23
# File 'lib/adva/static/import/model/page.rb', line 21

def attribute_names
  @attribute_names ||= super + [:body]
end