gateway/app/models/cms/section.rb

43 lines
741 B
Ruby
Raw Normal View History

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
def persisted?
false
end
2022-11-27 13:09:16 +01:00
def initialize(page , index , section_data)
@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
@content = section_data
end
def template
@content["template"]
end
2022-11-26 18:07:20 +01:00
def id
@content["id"]
end
def save
false
end
def self.all
@page.sections
end
def self.find(page_name , section_id)
Page.new(name + ".yaml")
end
end
end