humble 0.0.1369313534 → 0.0.1374296843

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb370818a8538c204b75957aab9a054d19b437c2
4
- data.tar.gz: b91eb088e167f8c94df5e03e8217075986674e0d
3
+ metadata.gz: a07fd88ec8a4eb23bc2664ecb4e040b9810b7955
4
+ data.tar.gz: 2bc6434c1fe15d55d2319d429a952c6b65f23b13
5
5
  SHA512:
6
- metadata.gz: fe6cef272f2f15098ef34c5d5c938ebe4082670f7807de1aa3ac15acc90d5c70ec0650bad0ce7204149d30ce5973a0b5fa20341aa8d92bffc22b04c7c4ad4c2e
7
- data.tar.gz: 8f0e2bde46256c0e6c8d34c146a98d2168f1726c796f2d0e9c50ab4e4e05e2b6e5c2aac117cb4f75c05e8d1115099691836c516f852f3f05fa4e5f7e4e45fd2c
6
+ metadata.gz: 6d0cf9e612c4f542c55aa47f837de75629ae6da985a4350f6d4412e7acffaf448639eff0490d98a86f58f6e69955e0705b028670bbf1da770ad2568400fc40fc
7
+ data.tar.gz: 607bb277179bed53fa228c8b47e46fd51508e3f4e26fa362107ea4a4b3bd8bde0338de85ff431eeba67aba8ab4b7b7c0ffbdaf4e9a2f318979f520e23b479c35
@@ -1 +1 @@
1
- orm
1
+ humble
@@ -1 +1 @@
1
- ruby-2.0.0-p195
1
+ ruby-2.0.0-p247
@@ -10,7 +10,8 @@ module Humble
10
10
  end
11
11
 
12
12
  def save_using(connection, item)
13
- connection[@table.name].insert(@table.insert(item))
13
+ id = connection[@table.name].insert(@table.insert(item))
14
+ item.instance_variable_set('@id', id)
14
15
  end
15
16
 
16
17
  def is_for?(item)
@@ -12,5 +12,15 @@ module Humble
12
12
  block.call(@mapper.map_from(row))
13
13
  end
14
14
  end
15
+
16
+ def include?(item)
17
+ self.find do |x|
18
+ x.id == item.id
19
+ end
20
+ end
21
+
22
+ def inspect
23
+ "[#{self.map { |x| x.inspect }.join(", ")}]"
24
+ end
15
25
  end
16
26
  end
@@ -23,7 +23,7 @@ describe "orm" do
23
23
 
24
24
  context "when fetching all items" do
25
25
  before :each do
26
- connection[:movies].insert(:name => 'monsters inc')
26
+ @id = connection[:movies].insert(:name => 'monsters inc')
27
27
  end
28
28
 
29
29
  let(:results) { session.find_all Movie }
@@ -39,12 +39,18 @@ describe "orm" do
39
39
  it "should return instances of the target type" do
40
40
  results.first.should be_instance_of(Movie)
41
41
  end
42
+
43
+ it "should include the saved movie" do
44
+ results.should include(Movie.new(:id => @id, :name => 'monsters inc'))
45
+ end
42
46
  end
43
47
 
44
48
  context "when inserting a new record" do
49
+ let(:movie) { Movie.new(:name => 'oop') }
50
+
45
51
  before :each do
46
52
  session.begin_transaction do |session|
47
- session.save(Movie.new(:name => 'oop'))
53
+ session.save(movie)
48
54
  end
49
55
  end
50
56
 
@@ -62,6 +68,10 @@ describe "orm" do
62
68
  it "should insert the name" do
63
69
  results.first[:name].should == 'oop'
64
70
  end
71
+
72
+ it "should update the new item with the new id" do
73
+ movie.id.should_not == -1
74
+ end
65
75
  end
66
76
 
67
77
  end
@@ -2,7 +2,7 @@ class Movie
2
2
  attr_reader :id, :name
3
3
 
4
4
  def initialize(attributes)
5
- @id = attributes[:name] || -1
5
+ @id = attributes[:id] || -1
6
6
  @name = attributes[:name]
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1369313534
4
+ version: 0.0.1374296843
5
5
  platform: ruby
6
6
  authors:
7
7
  - mo khan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-23 00:00:00.000000000 Z
11
+ date: 2013-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel