Skip to content

Instantly share code, notes, and snippets.

# For a sailing club - so they can define their own booking types....
# model: booking_type.rb
class BookingType
include DataMapper::Resource
# properties
property :id, Integer, :serial => true
property :name, String, :nullable => false
property :name_permalink, String # pluralized 'permalinked' version of name
# **********************************************************************
# *** with load_classes_with_requirements as per current merb source ***
# **********************************************************************
# --------------------------------------------------------------------------------------------
# The datamapper models I've been having probs with
# admin_entered_new_membership.rb
puts "loading AdminEnteredNewMembership"
class AdminEnteredNewMembership < MembershipApplication
# ***************************************************
# *** with load_classes_with_requirements patched ***
# ***************************************************
# --------------------------------------------------------------------------------------------
# The datamapper models I've been having probs with
# admin_entered_new_membership.rb
puts "loading AdminEnteredNewMembership"
class AdminEnteredNewMembership < MembershipApplication
module DataMapper
module Is
module StateMachine
# hook may be either a Proc or symbol
def run_hook_if_present(hook)
return true unless hook
if hook.respond_to?(:call)
hook.call(self)
else
From 42c65f3201d294613d0549bf8312f4b01e91ae00 Mon Sep 17 00:00:00 2001
From: Rupert Voelcker <rupert@rupespad.com>
Date: Mon, 13 Apr 2009 16:22:02 +0100
Subject: [PATCH] fix for more complex has many through
---
.../nested_attributes.rb | 2 +-
spec/fixtures/photo.rb | 9 +
spec/fixtures/tag.rb | 12 ++
spec/fixtures/tagging.rb | 10 +
module Merb
class MailController
def dispatch_and_deliver(method, mail_params)
non_array = mail_params.dup.delete_if { |k,v| v.is_a?(Array) }
array = mail_params.dup.delete_if { |k,v| !v.is_a?(Array) }
@mailer = self.class._mailer_klass.new(non_array)
@mail = @mailer.mail
@method = method
require 'rubygems'
require 'dm-core'
class User
include DataMapper::Resource
property :id, Serial
end
class Paper
@roovo
roovo / coverage.rake
Created December 13, 2010 12:38
for generating coverage with rspec 2 in ruby 1.9.2 using Simplecov
Rake.application.instance_variable_get('@tasks').delete('spec:rcov')
module SimpleCov
class RakeTask < ::Rake::TaskLib
def initialize(*args)
desc "Run RSpec code examples"
task(args.shift || :simplecov) do
RakeFileUtils.send(:verbose, true) do
if files_to_run.empty?
@roovo
roovo / fulcrum-jasmine-firefox-bfb78b164
Created September 8, 2011 06:56
the output wot I got
86 specs, 3 failures in 0.628sFinished at Thu Sep 08 2011 07:44:01 GMT+0100 (BST)
runStoryCollection collection
runposition
runshould return stories in position order
runshould move between 2 other stories
runshould move after another story
runshould move after the last story
runshould move before the first story
runshould move before another story
runshould return the story after a given story
var _user$project$Native_CanvasTexture = function() {
function higherPow2(aSize){
return Math.pow(2, Math.ceil(Math.log(aSize) / Math.log(2)));
}
function makeTextCanvas(context, text, fontSize, width, height) {
context.canvas.width = width;
context.canvas.height = height;
context.clearRect(0, 0, context.canvas.width, context.canvas.height);