Class: Adva::Static::Import::Model::Blog
- Defined in:
- lib/adva/static/import/model/blog.rb
Instance Attribute Summary
Attributes inherited from Base
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
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/adva/static/import/model/blog.rb', line 7 def recognize(sources) return [] if sources.blank? sources = Array(sources) posts = sources.select { |source| Post.permalink?(source) } posts = sources.map(&:directory).map(&:files).flatten.select { |s| Post.permalink?(s) } if posts.blank? blogs = posts.map { |post| Post.new(post).section_source }.flatten.uniq blogs = blogs.map { |blog| sources.detect { |source| blog.path == source.path } || blog } sources.replace(sources - blogs - posts.map(&:self_and_parents).flatten) blogs.map { |source| new(source) } end |
Instance Method Details
#attribute_names ⇒ Object
22 23 24 |
# File 'lib/adva/static/import/model/blog.rb', line 22 def attribute_names @attribute_names ||= super + [:posts_attributes] end |