Moved to https://gist.github.com/dkubb/28403
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT humans.id | |
, humans.first_name | |
, humans.middle_name | |
, humans.last_name | |
FROM humans | |
INNER JOIN ownerships ON ownerships.human_id = humans.id | |
INNER JOIN pets ON ownerships.pet_id = pets.id | |
WHERE pets.name = 'Bo' | |
GROUP BY humans.id | |
, humans.first_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Interfaces | |
========== | |
Finder Interface | |
---------------- | |
- [] | |
- all | |
- at | |
- fetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REQUIRED | |
-------- | |
* addressable | |
sudo gem install addressable | |
* extlib | |
git clone git://github.com/datamapper/extlib.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am pleased to announce the release of DataMapper 0.10.0 Release Candidate 1. | |
For the impatient, here are the command line instructions to install it: | |
Install | |
------- | |
1) Add gems.datamapper.org as a gem source: | |
gem sources --add http://gems.datamapper.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dm-core' | |
require 'dm-types' | |
class CrawledURI | |
include DataMapper::Resource | |
storage_names[:default] = 'crawled_uris' | |
property :id, Serial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== Interfaces | |
=== Finder Interface | |
+ #[] | |
+ #all | |
+ #at | |
- #fetch | |
+ #first | |
+ #first_or_create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BaseModel | |
def self.included(model) | |
model.class_eval <<-RUBY, __FILE__, __LINE__ + 1 | |
include DataMapper::Resource | |
property :id, Serial | |
timestamps :at | |
RUBY | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -KU | |
require 'rubygems' | |
require 'dm-core' | |
require 'dm-validations' | |
require 'pp' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post '/user/permissions' do | |
require_permission_to 'administer permissions' | |
params[:permissions].each do |role_id, permission_ids| | |
next unless role = Role.get(role_id) | |
role.update(:permissions => Permission.all(:id => permission_ids.keys)) | |
end | |
redirect '/user/permissions' | |
end |