Store::ActiveRecord
ActiveRecord DataMapper for Store.
It implements basic features such as insert, update, delete, single_find, bulk_find and count.
Installation
Add this line to your application's Gemfile:
gem 'store-active_record'
And then execute:
$ bundle
Or install it yourself as:
$ gem install store-active_record
Usage
Each table needs at least a uid column.
With Rails
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :uid
end
end
end
rake db:migrate
Without Rails
ActiveRecord::Migration.create_table('users') do |t|
t.string :uid
end
Establish connection to the database
require 'activerecord'
spec = YAML.load_file(path_to_your_database_yml)['production']
# database.yml
#
# development:
# adapter: sqlite3
# encoding: utf8
# collation: utf8_general_ci
# reconnect: false
# database: database_name
#
# test:
# adapter: sqlite3
# encoding: utf8
# collation: utf8_general_ci
# reconnect: false
# database: database_name_test
#
# production: development
ActiveRecord::Base.establish_connection(spec)
require 'store/active_record'
module DataMapper
module User
class ActiveRecord < Store::DataMapper::ActiveRecord
end
end
end
DataMapper::User::ActiveRecord.new('users')
Tests
Run against shared specs implemented in store-spec.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request