gateway/app/models/cms/page.rb
2022-11-25 16:03:39 +02:00

38 lines
613 B
Ruby

module Cms
class Page
include ActiveModel::Model
include ActiveModel::Conversion
include ActiveModel::Dirty
@@files = Set.new Dir.new(Rails.root.join("cms")).children
attr_reader :name , :content
def id
@name
end
def persisted?
false
end
def initialize file_name
@name = file_name.split(".").first
@content = YAML.load_file(Rails.root.join("cms" , file_name))
end
def template
@content[0]["template"]
end
def save
false
end
def self.all
@@files.collect{ |file| Page.new(file) }
end
end
end