Vorm
Simple ORM for Ruby.
This is a rewrite, and still under development.
Installation
Add this line to your application's Gemfile:
gem 'vorm'
And then execute:
$ bundle
Or install it yourself as:
$ gem install vorm
Usage
Inherit from Vorm::Model
to get the goodies.
class User < Vorm::Model
# table name
table 'users'
# field names
field 'email'
field 'phonenumber'
# validators
validate 'email' do |email|
# field will be passed to block
# if it isn't empty, so here !email.nil?
"Email not valid" if email !~ /@/
end
# callbacks
def self.create!(*args)
parent_said = super(args)
# send email, or whateva
SignUpMailer.send_welcome(parent_said.id)
# return what my mama said
parent_said
end
end
Contributing
- Fork it ( https://github.com/vastus/vorm/fork )
- 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 a new Pull Request