Skip to content

Instantly share code, notes, and snippets.

View dbussink's full-sized avatar

Dirkjan Bussink dbussink

View GitHub Profile
resources :people, :collection => {:search => :get}, :member => {:calculator => :post}
message = "Resource#id is deprecated. Either use Resource#key to retrieve the key(s) or use "
message << "one of " if key.size > 1
message << key_properties.map {|property| "#{self.class.to_s}##{property.name.to_s}" }.join(", ")
warn(message)
diff --git a/spec/lib/resource_shared_spec.rb b/spec/lib/resource_shared_spec.rb
index 6c2bad8..76cabe8 100644
--- a/spec/lib/resource_shared_spec.rb
+++ b/spec/lib/resource_shared_spec.rb
@@ -209,4 +209,129 @@ share_examples_for 'A Resource' do
end
end
+
+ it 'should respond to #eql?'
1)
'DataMapper::Associations::OneToMany::Proxy#delete_at with an index within the Collection should be the expected Resource' FAILED
expected: #<Article id=1 title="Sample Article" content="Sample" article_id=nil author_id=1>,
got: #<Article id=1 title="Sample Article" content="Sample" article_id=nil author_id=nil> (using ==)
/Users/dirkjan/Documents/projects/dm-core-spec/spec/lib/collection_shared_spec.rb:476:
2)
'DataMapper::Associations::OneToMany::Proxy#shift should be the first Resource in the Collection' FAILED
expected: #<Article id=1 title="Sample Article" content="Sample" article_id=nil author_id=1>,
got: #<Article id=1 title="Sample Article" content="Sample" article_id=nil author_id=nil> (using ==)
diff --git a/lib/dm-core/collection.rb b/lib/dm-core/collection.rb
index 0e2938d..c094100 100644
--- a/lib/dm-core/collection.rb
+++ b/lib/dm-core/collection.rb
@@ -634,11 +634,7 @@ module DataMapper
#
# @api public
def update(attributes = {}, *allowed)
- unless attributes.empty?
- each { |r| r.update(attributes, *allowed) }
match("/week/:week") do
resources :people, :name_prefix => "week", :resource_prefix => "Week" do
resources :addresses
end
end
resource(Week.new(2008, 10), Person.first)
===============================
class Person
property :id
property :name
has n, :addresses
end
class Address
include DataMapper::Resource
t = Thread.new do
puts "It's: #{Time.now}"
sleep(10)
puts "It's: #{Time.now}"
end
sleep(4)
t.wakeup
t.join
Changing the FK
Person
has n, :addresses
Address
belongs_to :person
@address = Address.first
@person = @address.person
Address.new(:person => person)
person.addresses.new()
person.addresses << Address.new()