Sha256: c9488cfbabc23a202675619b24e210ec7490af713a8d345ff435a0581d9406d5

Contents?: true

Size: 575 Bytes

Versions: 9

Compression:

Stored size: 575 Bytes

Contents

require 'yaml/store'

module Merb
  # thanks to Michael Fellinger from Ramaze
  class SimpleModel
    attr_accessor :db
  
    def initialize(filename = "#{DIST_ROOT}/schema/db.yaml")
      FileUtils.touch(filename)
      @db = YAML::Store.new(filename)
    end
  
    def method_missing(meth, *args, &block)
      @db.transaction do
        @db.send(meth, *args, &block)
      end
    end
    
    def [](key)
      @db.transaction do
        @db[key]
      end
    end
  
    def []=(key, value)
      @db.transaction do
        @db[key] = value
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
merb-0.0.8 lib/merb/merb_yaml_store.rb
merb-0.0.9 lib/merb/merb_yaml_store.rb
merb-0.2.0 lib/merb/merb_yaml_store.rb
merb-0.3.0 lib/merb/merb_yaml_store.rb
merb-0.3.1 lib/merb/merb_yaml_store.rb
merb-0.3.3 lib/merb/merb_yaml_store.rb
merb-0.3.4 lib/merb/merb_yaml_store.rb
merb-0.3.7 lib/merb/merb_yaml_store.rb
merb-0.1.0 lib/merb/merb_yaml_store.rb