module Middleman::DataModel

Constants

VERSION

Public Instance Methods

default_options() click to toggle source
# File lib/middleman-data_model.rb, line 16
def default_options
  { model_dir: "data" }
end
included() click to toggle source
# File lib/middleman-data_model.rb, line 36
def included ; registered ; end
load_models_with_app_data_hook(app) click to toggle source
# File lib/middleman-data_model.rb, line 28
def load_models_with_app_data_hook(app)
  app.before do
    SimpleDataModel.models.each do |model|
      model.data = data.send(model.data_name)
    end
  end
end
model_paths(path) click to toggle source
# File lib/middleman-data_model.rb, line 24
def model_paths(path)
  Dir["#{path}/**/*.rb"]
end
registered(app, options_hash = {}) click to toggle source
# File lib/middleman-data_model.rb, line 9
def registered(app, options_hash = {})
  options_hash = default_options.merge options_hash

  require_models(options_hash[:model_dir])
  load_models_with_app_data_hook(app)
end
require_models(path) click to toggle source
# File lib/middleman-data_model.rb, line 20
def require_models(path)
  model_paths(path).each {|file| require file }
end