sentiql 0.2.5 → 0.3.0

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.
@@ -11,14 +11,18 @@ class TestTables < ActiveRecord::Migration
11
11
  t.timestamps
12
12
  end
13
13
 
14
- create_table :after_save do |t|
14
+ create_table :clubs do |t|
15
+ t.string :name
16
+ t.text :desc
17
+ t.text :reqs
18
+
15
19
  t.timestamps
16
20
  end
17
21
  end
18
22
 
19
23
  def self.down
20
24
  drop_table :users
21
- drop_table :after_save
25
+ drop_table :clubs
22
26
  end
23
27
 
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module SentiQL
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/sentiql.rb CHANGED
@@ -23,6 +23,12 @@ module SentiQL
23
23
  @attrs[key] = value
24
24
  end
25
25
 
26
+ def update_attributes hash
27
+ new_attrs = hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
28
+ new_attrs.delete(:id)
29
+ @attrs = @attrs.merge(new_attrs)
30
+ end
31
+
26
32
 
27
33
  def save
28
34
 
data/spec/sentiql_spec.rb CHANGED
@@ -61,6 +61,24 @@ describe SentiQL::Base do
61
61
  end
62
62
  end
63
63
 
64
+ describe '.updated_all' do
65
+
66
+ it "updates model attrs" do
67
+ u = User.create :name=>'Natalie'
68
+ u.update_attributes({:full_name=>'Natalie Portman', :email=>'natalie@portman.com'})
69
+ u.save
70
+ uu = User.find_by :id=>u.id
71
+ uu.full_name.should == 'Natalie Portman'
72
+ uu.email.should == 'natalie@portman.com'
73
+ end
74
+
75
+ it "ignores :id in new attributes hash" do
76
+ u = User.create :name=>'Natalie'
77
+ lambda { u.update_attributes({:id=>'1111', :full_name=>'Natalie Portman', :email=>'natalie@portman.com'}) }.should_not change(u, :id)
78
+ end
79
+
80
+ end
81
+
64
82
  describe '.save' do
65
83
  it "creates new record if instance is new" do
66
84
  u = User.new :name=>'Natalie'
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 5
9
- version: 0.2.5
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Martynas Miliauskas
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-27 00:00:00 +01:00
17
+ date: 2011-05-28 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency