ohm 0.0.20 → 0.0.21
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.
- data/lib/ohm.rb +8 -8
- data/lib/ohm/redis.rb +1 -1
- data/test/connection_test.rb +1 -1
- data/test/model_test.rb +13 -1
- metadata +2 -2
data/lib/ohm.rb
CHANGED
@@ -459,7 +459,7 @@ module Ohm
|
|
459
459
|
end
|
460
460
|
|
461
461
|
def initialize(attrs = {})
|
462
|
-
@_attributes = Hash.new {|hash,key| hash[key] = read_remote(key) }
|
462
|
+
@_attributes = Hash.new { |hash, key| hash[key] = read_remote(key) }
|
463
463
|
update_attributes(attrs)
|
464
464
|
end
|
465
465
|
|
@@ -474,7 +474,7 @@ module Ohm
|
|
474
474
|
mutex do
|
475
475
|
create_model_membership
|
476
476
|
add_to_indices
|
477
|
-
|
477
|
+
write
|
478
478
|
end
|
479
479
|
end
|
480
480
|
|
@@ -484,7 +484,7 @@ module Ohm
|
|
484
484
|
|
485
485
|
mutex do
|
486
486
|
update_indices
|
487
|
-
|
487
|
+
write
|
488
488
|
end
|
489
489
|
end
|
490
490
|
|
@@ -561,6 +561,11 @@ module Ohm
|
|
561
561
|
self.class.key(id, *args)
|
562
562
|
end
|
563
563
|
|
564
|
+
def write
|
565
|
+
attributes.each { |att| write_remote(att, send(att)) }
|
566
|
+
self
|
567
|
+
end
|
568
|
+
|
564
569
|
private
|
565
570
|
|
566
571
|
def self.db
|
@@ -597,11 +602,6 @@ module Ohm
|
|
597
602
|
db.srem(self.class.key(:all), id)
|
598
603
|
end
|
599
604
|
|
600
|
-
def save!
|
601
|
-
attributes.each { |att| write_remote(att, send(att)) }
|
602
|
-
self
|
603
|
-
end
|
604
|
-
|
605
605
|
def update_indices
|
606
606
|
delete_from_indices
|
607
607
|
add_to_indices
|
data/lib/ohm/redis.rb
CHANGED
data/test/connection_test.rb
CHANGED
data/test/model_test.rb
CHANGED
@@ -23,6 +23,13 @@ class Event < Ohm::Model
|
|
23
23
|
attribute :name
|
24
24
|
counter :votes
|
25
25
|
set :attendees, Person
|
26
|
+
|
27
|
+
attribute :slug
|
28
|
+
|
29
|
+
def write
|
30
|
+
self.slug = name.to_s.downcase
|
31
|
+
super
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
class TestRedis < Test::Unit::TestCase
|
@@ -46,7 +53,6 @@ class TestRedis < Test::Unit::TestCase
|
|
46
53
|
end
|
47
54
|
|
48
55
|
context "An event updated from a hash of attributes" do
|
49
|
-
|
50
56
|
class Meetup < Ohm::Model
|
51
57
|
attribute :name
|
52
58
|
|
@@ -146,6 +152,12 @@ class TestRedis < Test::Unit::TestCase
|
|
146
152
|
|
147
153
|
assert_equal "Lorem", Event[event.id].name
|
148
154
|
end
|
155
|
+
|
156
|
+
should "allow to hook into write" do
|
157
|
+
event = Event.create(:name => "Foo")
|
158
|
+
|
159
|
+
assert_equal "foo", event.slug
|
160
|
+
end
|
149
161
|
end
|
150
162
|
|
151
163
|
context "Delete" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-09-
|
13
|
+
date: 2009-09-21 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|