lib/sportdb.rb in sportdb-0.3.0 vs lib/sportdb.rb in sportdb-0.3.1

- old
+ new

@@ -17,12 +17,20 @@ require 'active_record' ## todo: add sqlite3? etc. # our own code -require 'sportdb/schema' -require 'sportdb/models' +require 'sportdb/models/country' +require 'sportdb/models/event' +require 'sportdb/models/event_team' +require 'sportdb/models/game' +require 'sportdb/models/group' +require 'sportdb/models/group_team' +require 'sportdb/models/prop' +require 'sportdb/models/round' +require 'sportdb/models/team' +require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models) require 'sportdb/utils' require 'sportdb/loader' require 'sportdb/version' require 'sportdb/cli/opts' require 'sportdb/cli/runner' @@ -48,19 +56,35 @@ def self.load( args ) Loader.new.run( args ) end + class Deleter + ## todo: move into its own file??? + + ## make models available in sportdb module by default with namespace + # e.g. lets you use Team instead of Models::Team + include SportDB::Models + + def run( args=[] ) + # for now delete all tables + + Team.delete_all + Game.delete_all + Event.delete_all + EventTeam.delete_all + Group.delete_all + GroupTeam.delete_all + Round.delete_all + Prop.delete_all + Country.delete_all + end + + end + # delete ALL records (use with care!) def self.delete! - Team.delete_all - Game.delete_all - Event.delete_all - EventTeam.delete_all - Group.delete_all - GroupTeam.delete_all - Round.delete_all - Prop.delete_all + Deleter.new.run end # method delete! end # module SportDB \ No newline at end of file