Sha256: 42b31b4c1d27b98093ef1f60bd5453f9a3bd09f8c78ba31e873ca1869a89abcf
Contents?: true
Size: 1.86 KB
Versions: 6
Compression:
Stored size: 1.86 KB
Contents
# encoding: UTF-8 module Spontaneous class BoxStyle < Style attr_reader :box def self.to_directory_name(klass) return nil if excluded_classes.include?(klass) super end def initialize(box, owner = nil) @box = box @owner = box.owner.class end def inline_template(format) nil end def try_supertype_styles(renderer) [] end def name box._name.to_s end def try_paths prototype = box._prototype box_name = box._name.to_s paths = owner_directory_paths(box_name) if style_name = prototype.default_style name = style_name.to_s paths.concat(owner_directory_paths(name)) paths.concat(box_directory_paths(name)) end if box.styles.empty? paths.concat(box_directory_names) else unless style_name = prototype.default_style box.styles.each do |style| name = style.name.to_s paths.concat(owner_directory_paths(name)) paths.concat(box_directory_paths(name)) end end end paths end def box_directory_names box_class = box._prototype.box_base_class box_supertypes = [box_class].concat(class_ancestors(box_class)).reject { |type| excluded_classes.include?(type) } return [nil] if box_supertypes.empty? box_supertypes.map { |type| to_directory_name(type) } end def excluded_classes model = box.model.content_model [Spontaneous::Box, model::Box].tap do |classes| classes.push(::Box) if defined?(::Box) end end def to_directory_name(klass) return nil if excluded_classes.include?(klass) super end def box_directory_paths(name) box_directory_names.map { |d| [d, name] } end def anonymous_template Proc.new { '${ render_content }' } end end end
Version data entries
6 entries across 6 versions & 1 rubygems