2022-11-25 17:56:46 +01:00
|
|
|
module Cms
|
|
|
|
class Section
|
|
|
|
include ActiveModel::Model
|
|
|
|
include ActiveModel::Conversion
|
|
|
|
include ActiveModel::Dirty
|
|
|
|
|
2022-11-27 13:09:16 +01:00
|
|
|
attr_reader :name , :content , :page , :index
|
2022-11-25 17:56:46 +01:00
|
|
|
|
|
|
|
def persisted?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2022-11-27 13:09:16 +01:00
|
|
|
def initialize(page , index , section_data)
|
2022-11-25 17:56:46 +01:00
|
|
|
@page = page
|
2022-11-27 13:09:16 +01:00
|
|
|
raise "No number #{index}" unless index.is_a?(Integer)
|
|
|
|
raise "No has #{section_data}" unless section_data.is_a?(Hash)
|
|
|
|
@index = index
|
2022-11-25 17:56:46 +01:00
|
|
|
@content = section_data
|
|
|
|
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
|