Module: Spree::Sample

Defined in:
lib/spree/sample.rb

Class Method Summary collapse

Class Method Details

.load_sample(file) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/spree/sample.rb', line 3

def self.load_sample(file)
  # If file exists within application it takes precendence.
  if File.exists?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
    path = File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
  else
    # Otherwise we will use this gems default file.
    path = File.expand_path(samples_path + "#{file}.rb")
  end
  # Check to see if the specified file has been loaded before
  if !$LOADED_FEATURES.include?(path)
    require path
    puts "Loaded #{file.titleize} samples"
  end
end