start on card editing

This commit is contained in:
2022-11-30 11:22:45 +02:00
parent 5ade5c6c19
commit 277d4dce36
26 changed files with 187 additions and 19 deletions

16
app/models/merged/card.rb Normal file
View File

@ -0,0 +1,16 @@
module Merged
class Card
include ActiveModel::API
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_reader :content , :section
def initialize(section , card_data)
@section = section
raise "No data #{card_data}" unless card_data.is_a?(Hash)
@content = card_data
end
end
end

View File

@ -13,7 +13,7 @@ module Merged
def initialize(page , index , section_data)
@page = page
raise "No number #{index}" unless index.is_a?(Integer)
raise "No has #{section_data}" unless section_data.is_a?(Hash)
raise "No hash #{section_data}" unless section_data.is_a?(Hash)
@index = index
@content = section_data
end
@ -28,6 +28,12 @@ module Merged
@content[key] = value
end
def cards
element = @content["cards"]
return [] if element.nil?
element.collect{|card_content| Card.new(self , card_content)}
end
def template
@content["template"]
end