base class for styles

This commit is contained in:
Torsten 2022-12-16 16:49:26 +02:00
parent 22f21225a1
commit 46987dac70
4 changed files with 24 additions and 29 deletions

View File

@ -1,22 +1,11 @@
module Merged module Merged
class CardStyle < ActiveYaml::Base class CardStyle < Style
set_root_path Engine.root + "config"
fields :template , :text , :header, :fields fields :template , :text , :header, :fields
def card_preview def card_preview
"merged/card_preview/" + template "merged/card_preview/" + template
end end
def options_definitions
option_defs = []
options.each do |name|
option = OptionDefinition.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if options
option_defs
end
end end
end end

View File

@ -1,7 +1,5 @@
module Merged module Merged
class PageStyle < ActiveYaml::Base class PageStyle < Style
set_root_path Engine.root + "config"
fields :type , :description fields :type , :description
end end

View File

@ -1,7 +1,6 @@
module Merged module Merged
class SectionStyle < ActiveYaml::Base class SectionStyle < Style
set_root_path Engine.root + "config"
fields :template , :text , :header, :fields , :cards fields :template , :text , :header, :fields , :cards
def has_cards? def has_cards?
@ -12,15 +11,5 @@ module Merged
"merged/section_preview/" + template "merged/section_preview/" + template
end end
def options_definitions
option_defs = []
options.each do |name|
option = OptionDefinition.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if options
option_defs
end
end end
end end

View File

@ -0,0 +1,19 @@
module Merged
class Style < ActiveYaml::Base
set_root_path Engine.root + "config"
fields :options
def options_definitions
option_defs = []
options.each do |name|
option = OptionDefinition.find_by_name(name)
raise "no option for #{name}:#{name.class}" if option.blank?
option_defs << option
end if options
option_defs
end
end
end