merged/app/models/merged/shared_base.rb

18 lines
608 B
Ruby
Raw Normal View History

2023-01-27 16:17:05 +01:00
module Merged
# shared data across engine and app
# takes a little footwork, as seen below
class SharedBase < ActiveYaml::Base
def self.raw_data
2023-01-27 18:08:57 +01:00
paths = [ Merged::Engine.root.join("config") , Rails.root.join(Merged.data_dir) ]
2023-01-27 16:17:05 +01:00
loaded_files = paths.collect do |path|
actual_filename = filename || name.tableize
full = File.join(path, "#{actual_filename}.#{extension}")
2023-01-27 18:08:57 +01:00
got = load_path(full)
raise "#{full} contained #{got.class}, not Array" unless got.class == Array
got
2023-01-27 16:17:05 +01:00
end
2023-01-29 17:34:51 +01:00
loaded_files.first + loaded_files.last
2023-01-27 16:17:05 +01:00
end
end
end