Mapper#loader(body) => [Loader] # Loader for specific body
Mapper#dumper(object) => [Dumper] # Dumper for object
Mapper#execute(command) # command is an instance of DataMapper::Session::Command::{Insert,Update,Delete}
Loader#identity => [Identity] # Any mapper specific object that implements#hash
Loader#object => [Object] # The loaded domain object
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 'spec_helper' | |
describe AliasSet, '#initialize' do | |
let(:prefix) { :songs } | |
let(:attributes) { Mapper::AttributeSet.new << attribute } | |
let(:attribute) { Mapper::Attribute.build(:id, :type => Integer) } | |
let(:excluded) { [ :id ] } | |
context 'with prefix passed to #initialize' do | |
subject { described_class.new(prefix) } |
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 MethodObject < Module | |
def initialize(output_name) | |
@output_name = output_name | |
end | |
module InstanceMethods | |
attr_reader :input | |
def initialize(input) | |
@input = input |
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
# encoding: UTF-8 | |
require "rubygems" | |
require "bundler/setup" | |
require 'json' | |
# File.delete "/tmp/sqlite-bug-report-test" | |
require 'dm-core' | |
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
# In reference to my discussion with shingara and http://stackoverflow.com/questions/13294788/how-can-i-have-a-datamapper-callback-happen-in-a-transaction/13444988#13444988 | |
class SomeRailsController | |
def update | |
comment = Comment.get(params[:id]) | |
return not_found unless comment | |
text = params[:text] | |
update = CommentUpdater.run(comment, text) | |
if update.successful? |
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
# Scenario when Classes and Modules are duped in memoizers! | |
class A | |
include Adamantium::Flat | |
def foo | |
:foo | |
end | |
memoize :foo | |
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
describe User, '.with_first_name' do | |
let(:object) { described_class } | |
subject { object.with_first_name(name) } | |
let(:result) { mock('Result') } | |
let(:name) { mock('Name') } | |
before do | |
User.stub(:all => result) |
This list is not official, definitive or in some other kind authoritative or ordered by importance / priority.
- adamantium | Support lib to make objects immutable
- equalizer | Equalize on public attributes
- descendants_tracker | Track structure of inheritance trees
- abstract_class | Declare abstract classes and methods
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
# Solves the leak by nuking dynamically generated subclasses from vm | |
def clean | |
RSpec::Core::ExampleGroup.children.clear | |
RSpec::Core::ExampleGroup.constants.each do |name| | |
if name =~ /^Nested/ | |
RSpec::Core::ExampleGroup.send(:remove_const, name) | |
end | |
end | |
end |