2022-11-25 17:56:46 +01:00
|
|
|
module Cms
|
|
|
|
class Section
|
|
|
|
include ActiveModel::Model
|
|
|
|
include ActiveModel::Conversion
|
|
|
|
include ActiveModel::Dirty
|
|
|
|
|
|
|
|
attr_reader :name , :content , :page
|
|
|
|
|
|
|
|
def persisted?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(page , section_data)
|
|
|
|
@page = page
|
|
|
|
@content = section_data
|
|
|
|
# id = SecureRandom.hex(10) if new or not there
|
|
|
|
end
|
|
|
|
|
|
|
|
def template
|
|
|
|
@content["template"]
|
|
|
|
end
|
|
|
|
|
2022-11-26 18:07:20 +01:00
|
|
|
def id
|
|
|
|
@content["id"]
|
|
|
|
end
|
|
|
|
|
2022-11-25 17:56:46 +01:00
|
|
|
def save
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.all
|
|
|
|
@page.sections
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.find(page_name , section_id)
|
|
|
|
Page.new(name + ".yaml")
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|