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
// Shared Experience textarea blocker | |
$('#experience textarea#experience_body').bind('keypress', function(){ | |
$('a').attr('rel', 'blocked'); | |
}); | |
// Be alert! The world needs more Lerts. | |
$('a[rel="blocked"]').click(function(){ | |
alert('Sorry, This is just a demo!'); | |
return false; | |
}); |
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
$.extend({ | |
param: function( a, nest_in ) { | |
var s = [ ]; | |
// check for nest | |
if (typeof nest_in == 'undefined') nest_in = false; | |
function nested(key) { | |
if (nest_in) | |
return nest_in + '[' + key + ']'; | |
else |
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
class Parent | |
include DataMapper::Resource | |
def self.default_repository_name | |
:parent_repo | |
end | |
property :id, Serial | |
has n, :children, :model => "StiBase" |
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 'rubygems' | |
# puts ENV["GEM_HOME"] | |
require 'ruby-debug' | |
require 'datamapper' | |
DataMapper::Logger.new(STDOUT) | |
DataMapper.setup(:default, "sqlite::memory:") | |
class Page | |
include DataMapper::Resource |
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
-- Retrieve descendants | |
-- ==================== | |
-- retrieve descendants of #4 | |
SELECT c.* | |
FROM Comments AS c | |
JOIN TreePaths AS t ON c.comment_id = t.descendant | |
WHERE t.ancestor = 4; | |
-- Retrieve ancestors |
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 "rubygems" | |
require "datamapper" | |
DataMapper::Logger.new($stdout, :default) | |
DataMapper.setup(:default, "sqlite::memory:") | |
class Source | |
include DataMapper::Resource | |
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
DataMapper::Logger.new($stdout, :default) | |
DataMapper.setup(:default, "sqlite::memory:") | |
class Author | |
include DataMapper::Resource | |
property :id, Serial | |
property :email, String | |
has n, :posts |
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
# TODO: shouldn't Validations use `before :save` to intercept the save call? | |
# (for DataMapper::Resource instances, not validated plain Ruby objects) | |
# | |
# Admittedly, it may not be possible to support as 'clean' of an interface | |
# from the caller's perspective (ie., being able to specify the validation | |
# context with an arg to the #save/#update methods vs in some other manner). | |
# | |
# However, changing the method signature of #save and #update is problematic. | |
# Also, I'm not sure how often an explicit validation context is used, | |
# and on that basis I question whether the interface should be designed for |
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
begin | |
begin | |
raise "test" | |
rescue Exception => e | |
puts "Rescuing #{e.inspect}" | |
end | |
ensure | |
puts "Ensuring #{e.inspect}" | |
raise e if e | |
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
require "rubygems" | |
require "datamapper" | |
DataMapper.setup(:default, "sqlite::memory:") | |
DataMapper::Logger.new(STDOUT, :debug) | |
class Recipe | |
include DataMapper::Resource | |
property :id, Serial |
OlderNewer