Sha256: e213eadfc290a029e3bc6170d8b4c398eb8df5e565c1572a59c4f58dfa93dd02

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 KB

Contents

class Kiss
  # This module is included into Sequel database class to provide Kiss-specific
  # fnctionality to database objects.
  module SequelDatabase
    
    def self.append_features(mod)
      mod.class_eval do
        alias_method :execute_old, :execute
        _attr_accessor :kiss_controller, :kiss_request, :kiss_model_cache
        
        def execute(sql, *args, &block)   #:nodoc:
          @_last_query = sql
          execute_old(sql, *args, &block)
        end
      end
      super
    end
  
    @_last_query = nil
    def last_query   #:nodoc:
      @_last_query
    end
    
      # Returns Sequel dataset to evolution_number table, which specifies 
      # app's current evolution number.
    # Creates evolution_number table if it does not exist.
    def evolution_number_table
      unless self.table_exists?(:evolution_number)
        self.create_table :evolution_number do
          column :version, :integer, :null=> false
        end
        self[:evolution_number].insert(:version => 0)
      end
      self[:evolution_number]
    end

    # Returns app's current evolution number.
    def evolution_number
      evolution_number_table.first.version
    end

    # Sets app's current evolution number.
    def evolution_number=(version)
      evolution_number_table.update(:version => version)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kiss-1.8.9 lib/kiss/ext/sequel_database.rb
kiss-1.8.8 lib/kiss/ext/sequel_database.rb
kiss-1.8.7 lib/kiss/ext/sequel_database.rb
kiss-1.8.6 lib/kiss/ext/sequel_database.rb
kiss-1.8.5 lib/kiss/ext/sequel_database.rb
kiss-1.8.4 lib/kiss/ext/sequel_database.rb
kiss-1.8.3 lib/kiss/ext/sequel_database.rb
kiss-1.8.2 lib/kiss/ext/sequel_database.rb
kiss-1.8.1 lib/kiss/ext/sequel_database.rb
kiss-1.8 lib/kiss/ext/sequel_database.rb
kiss-1.7.4 lib/kiss/ext/sequel_database.rb
kiss-1.7.2 lib/kiss/ext/sequel_database.rb
kiss-1.7.1 lib/kiss/ext/sequel_database.rb
kiss-1.7 lib/kiss/ext/sequel_database.rb