Skip to content

Instantly share code, notes, and snippets.

View zdzolton's full-sized avatar

Zach Zolton zdzolton

View GitHub Profile
@zdzolton
zdzolton / model.rb
Created May 7, 2009 18:13
CouchRestExt::Model – for Rails + CouchRest happiness
module CouchRestExt
class Model < CouchRest::ExtendedDocument
include CouchRest::Validation
define_callbacks :validation
def valid?(context = :default)
_run_validation_callbacks do
self.class.validators.execute(context, self)
end
@zdzolton
zdzolton / blueprints.rb
Created May 7, 2009 18:10
Machinist-style Blueprint for CouchRest
class CouchRestExt::Model
class << self
def make attributes={}
new(@_blueprint_block.call.merge(attributes)).tap do |obj|
yield obj if block_given?
obj.save
end
end
function grapp {
find ./app -name "*.rb" |xargs fgrep --color $1;
}