Kiss A simpler, smarter web application framework for Ruby

Kiss::ModelCache Subclass of Object

Public Class Methods

model_dir=(model_dir = nil) source

Not documented

    # File lib/kiss/model.rb, line 66
    def self.model_dir=(model_dir = nil)
      @@model_dir = model_dir && ::File.directory?(model_dir) ? model_dir : nil
    end
    
new(database = nil) source

Not documented

    # File lib/kiss/model.rb, line 70
    def initialize(database = nil)
      @db = database
      @cache = {}
    end
    

Public Instance Methods

[](source) source

Not documented

    # File lib/kiss/model.rb, line 82
    def [](source)
      raise 'argument to model cache must be symbol of database table name' unless source.is_a?(Symbol)
      
      database = @db
      @@model_dir ? begin
        # use file_cache
        model_path = "#{@@model_dir}/#{source}.rb"
        Kiss.file_cache(model_path) do |src|
          klass = new_model_class(database,source)
          klass.class_eval(src,model_path) if src
          klass
        end
      end : @cache[source] ||= new_model_class(database,source)
    end
    
database() source

Not documented

    # File lib/kiss/model.rb, line 97
    def database
      @db
    end
    
Also aliased as: db
db() source

Alias for database

literal(*args) source

Not documented

    # File lib/kiss/model.rb, line 102
    def literal(*args)
      Sequel::Model.dataset.literal(*args)
    end
    
Also aliased as: quote
mdy_to_ymd(*args) source

Not documented

    # File lib/kiss/model.rb, line 107
    def mdy_to_ymd(*args)
      Kiss.mdy_to_ymd(*args)
    end
    
new_model_class(database,source) source

Not documented

    # File lib/kiss/model.rb, line 75
    def new_model_class(database,source)
      klass = Class.new(Kiss::Model)
      klass.set_dataset(database[source])
      klass.table = source
      klass
    end
    
quote(*args) source

Alias for literal

Disabled; run with $DEBUG to generate this.