class Cuttings::Greenhouse

Public Instance Methods

creatable_models() click to toggle source
# File lib/cuttings/greenhouse.rb, line 16
def creatable_models
  @creatable_models ||= []
end
process() click to toggle source
# File lib/cuttings/greenhouse.rb, line 20
def process
  truncate_models
  creatable_models.each(&:run)
end
seed(model_name, options = {}, &block) click to toggle source
# File lib/cuttings/greenhouse.rb, line 3
def seed(model_name, options = {}, &block)
  truncatable_models << model_name unless options.delete(:truncate) == false
  creatable_models << Cutting.new(model_name, options, &block)
end
truncatable_models() click to toggle source
# File lib/cuttings/greenhouse.rb, line 12
def truncatable_models
  @truncatable_models ||= []
end
truncate(*model_names) click to toggle source
# File lib/cuttings/greenhouse.rb, line 8
def truncate(*model_names)
  truncatable_models.concat(model_names.flatten)
end
truncate_models() click to toggle source
# File lib/cuttings/greenhouse.rb, line 25
def truncate_models
  truncatable_models.each do |model_name|
    model_name.constantize.destroy_all
  end
end