Sha256: db01b08713b763b6873ef0df185b86fec44e57dbc485b0612eb167dc28115765
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 KB
Contents
module Pageflow # Seed data that is used for published entires as well as editor # display. # # @api private module CommonEntrySeedHelper def common_entry_seed(entry) { locale: entry.locale, page_types: PageTypesSeed.new(entry, Pageflow.config_for(entry)).as_json } end class PageTypesSeed attr_reader :entry, :config def initialize(entry, config) @entry = entry @config = config end def as_json config.page_types.each_with_object({}) do |page_type, result| result[page_type.name.to_sym] = page_type_seed(page_type) end end private def page_type_seed(page_type) { thumbnail_candidates: thumbnail_candidates(page_type) } end def thumbnail_candidates(page_type) page_type.thumbnail_candidates.map do |candidate| { attribute: candidate[:attribute], collection_name: candidate[:file_collection], css_class_prefix: thumbnail_candidate_css_class_prefix(candidate) } end end def thumbnail_candidate_css_class_prefix(candidate) file_type = config.file_types.find_by_collection_name!(candidate[:file_collection]) file_type.model.model_name.singular end end end end
Version data entries
6 entries across 6 versions & 1 rubygems