Skip to content

Instantly share code, notes, and snippets.

View solnic's full-sized avatar

Peter Solnica solnic

View GitHub Profile
module DataMapper
class Property
class Textile < String
def load(value)
RedCloth.new(value.to_s).to_html
end
end
end
end
git "git://github.com/datamapper/dm-more.git", :branch => 'next'
gem 'dm-validations', '~> 0.10.3'
gem 'dm-aggregates', '~> 0.10.3'
gem 'dm-timestamps', '~> 0.10.3'
gem 'dm-types', '~> 0.10.3'
AbstractProperty:
public:
.accept_options
.accepted_options
.descendants
.options
.primitive
#allow_blank?
#allow_nil?
require 'dm-core'
require 'dm-migrations'
require 'dm-types'
DataMapper.setup(:default, "mysql://localhost/dm_core_test")
class Heffalump
include DataMapper::Resource
property :id, UUID, :key => true, :default => lambda{UUIDTools::UUID.random_create}
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-timestamps'
DataMapper.setup :default, 'sqlite3::memory:'
source 'http://rubygems.org'
group :runtime do
# We bundle both AS and extlib while extlib compatibility needs to be kept around.
# require 'dm-core' will ensure that only one is activated at any time though.
# This is done by trying to require AS components and fallback to requiring
# extlib in case a LoadError was rescued when requiring AS code.
#
# Due to bundle exec activating all groups in the Gemfile, it's recommended to run
#!/bin/bash
NAME="dm-types"
git clone --quiet --no-hardlinks dm-more $NAME
cd $NAME
git filter-branch --prune-empty --subdirectory-filter $NAME --tag-name-filter 'cat' -- --all
class Meta < DataMapper::Type
primitive ::Object
end
class User
include DataMapper::Resource
property :id, Serial
property :meta, Meta
end
module DataMapper
class Property
# the primitive is Integer so we inherit from Property::Integer
# to get the common behavior (typecasting, validation checking etc.)
# and predefined options
class CheckedInteger < Integer
OPTIONS = [ :gt, :gte, :lte, :lt ]
require 'dm-core'
DataMapper::Property::String.required true
class User
include DataMapper::Resource
property :id, Serial
property :name, String
end