module ES::Index::Tasks
Public Instance Methods
included_models()
click to toggle source
# File lib/es/index/tasks.rb, line 7 def included_models dir = ENV['DIR'].to_s != '' ? ENV['DIR'] : Rails.root.join("app/models") puts "Loading models from: #{dir}" included = [] Dir.glob(File.join("#{dir}/**/*.rb")).each do |path| model_filename = path[/#{Regexp.escape(dir.to_s)}\/([^\.]+).rb/, 1] next if model_filename.match(/^concerns\//i) # Skip concerns/ folder klass = model_filename.camelize.constantize begin klass = model_filename.camelize.constantize rescue NameError require(path) ? retry : raise end # Skip if the class doesn't have Toy::Dynamo integration next unless klass.respond_to?(:dynamo_table) included << klass end included end