Sha256: 58c58d4c9e8845ed3bafb2c45b24783afd5bcb41959c23af1b8a1998b2699a14
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module Coupler module Models class Project < Sequel::Model include CommonModel one_to_many :resources one_to_many :scenarios def local_database(&block) Sequel.connect(local_connection_string, { :loggers => [Coupler::Logger.instance], :max_connections => 50, :pool_timeout => 60 }, &block) end private def local_connection_string Coupler.connection_string("project_#{id}") end def before_validation super self.slug ||= name.downcase.gsub(/\s+/, "_") if name end def validate super validates_presence :name validates_unique :name, :slug end def after_destroy super FileUtils.rm(Dir[Coupler.db_path("project_#{id}")+".*"], :force => true) resources_dataset.each { |r| r.delete_versions_on_destroy = self.delete_versions_on_destroy; r.destroy } scenarios_dataset.each { |s| s.delete_versions_on_destroy = self.delete_versions_on_destroy; s.destroy } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coupler-0.0.9-java | lib/coupler/models/project.rb |
coupler-0.0.8-java | lib/coupler/models/project.rb |