module Spree::Sample

Public Class Methods

load_sample(file) click to toggle source
# File lib/spree/sample.rb, line 3
def self.load_sample(file)
  # If file exists within application it takes precendence.
  path = if File.exist?(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
           File.expand_path(File.join(Rails.root, 'db', 'samples', "#{file}.rb"))
         else
           # Otherwise we will use this gems default file.
           File.expand_path(samples_path + "#{file}.rb")
         end
  # Check to see if the specified file has been loaded before
  unless $LOADED_FEATURES.include?(path)
    require path
    puts "Loaded #{file.titleize} samples"
  end
end
samples_path() click to toggle source
# File lib/spree/sample.rb, line 18
def self.samples_path
  Pathname.new(File.join(File.dirname(__FILE__), '..', '..', 'db', 'samples'))
end