Module: Filebase::Model

Defined in:
lib/filebase/model.rb

Defined Under Namespace

Modules: Mixins

Class Method Summary collapse

Class Method Details

.[](path, driver = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/filebase/model.rb', line 9

def self.[]( path, driver=nil )
  Module.new do |mixin|
    ( class << mixin ; self ; end ).module_eval do
      define_method( :included ) do | model |
		      model.module_eval do
		        storage = driver ? Filebase::Drivers.const_get(driver.to_s) : Filebase.storage
		        @db = storage.new(path)
		        extend Mixins::ClassMethods ; include Attributes ;  include Mixins::InstanceMethods
		      end
		    end
    end
  end
end