lib/swift.rb in swift-0.14.0 vs lib/swift.rb in swift-1.0.0

- old
+ new

@@ -6,17 +6,15 @@ warn "WARNING: DateTime parsing will be slow without home_run gem on Rubies older than 1.9.3" end end # Extension. -require_relative '../ext/swift' require_relative 'swift/adapter' require_relative 'swift/adapter/sql' require_relative 'swift/attribute' -require_relative 'swift/db' require_relative 'swift/header' -require_relative 'swift/scheme' +require_relative 'swift/record' require_relative 'swift/type' # A rational rudimentary object relational mapper. # # == Synopsis @@ -24,11 +22,11 @@ # require 'swift/migrations' # # Swift.trace true # Debugging. # Swift.setup :default, Swift::DB::Postgres, db: 'swift' # -# class User < Swift::Scheme +# class User < Swift::Record # store :users # attribute :id, Swift::Type::Integer, serial: true, key: true # attribute :name, Swift::Type::String # attribute :email, Swift::Type::String # end # User @@ -97,12 +95,12 @@ # # other_users = User.prepare('select * from users where age > ?') # other_users.execute(32) # end # - # @param [Symbol] name Adapter name. - # @param [Proc] &block Scope this block to the named adapter instead of <tt>:default</tt>. + # @param [Symbol] name Adapter name. + # @param [Proc] block Scope this block to the named adapter instead of <tt>:default</tt>. # @return [Swift::Adapter] #-- # I pilfered the logic from DM but I don't really understand what is/isn't thread safe. def db name = nil, &block scopes = (Thread.current[:swift_db] ||= []) @@ -128,8 +126,12 @@ # Handy if you are brewing stuff like migrations and need a list of defined schema subclasses. # # @return [Array<Swift::Schema>] def schema @schema ||= [] + end + + def trace io = $stdout, &block + Swift.db.trace(io, &block) end end end # Swift