redis-orm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +8 -0
- data/README.md +2 -2
- data/Rakefile +8 -0
- data/lib/redis/actions/saving.rb +3 -1
- data/lib/redis/orm/version.rb +1 -1
- data/redis-orm.gemspec +2 -0
- data/spec/redis/actions/finding_spec.rb +4 -0
- data/test.rb +2 -2
- metadata +28 -5
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Inherit from `Redis::ORM` as if you were inheriting from `ActiveRecord::Base`:
|
|
28
28
|
# more code here!
|
29
29
|
end
|
30
30
|
|
31
|
-
At this point your
|
31
|
+
At this point your Users can be created, saved, and so forth. It might be helpful to define attributes on the model, however, or else the model will be quite useless indeed!
|
32
32
|
|
33
33
|
### attributes
|
34
34
|
|
@@ -67,7 +67,7 @@ There are 3 core relationships defined by `redis-orm`: `belongs_to`, `has_one` a
|
|
67
67
|
belongs_to :user
|
68
68
|
end
|
69
69
|
|
70
|
-
As
|
70
|
+
As shown above, you should usually follow your `has_one` and `has_many` directives with a `relation` option, which matches the corresponding `belongs_to` relation in the other models. Think of it as the `foreign_key` option in ActiveRecord. This option is not strictly required and `redis-orm` will work fine without it, but you may have problems looking up the reverse relations (e.g. the `belongs_to` part) without it.
|
71
71
|
|
72
72
|
Alternatively, you can specify a `relation` option for the `belongs_to` directive, instead:
|
73
73
|
|
data/Rakefile
CHANGED
data/lib/redis/actions/saving.rb
CHANGED
@@ -35,7 +35,9 @@ module Redis::Actions::Saving
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def define_id
|
38
|
-
|
38
|
+
# model_name.to_s is required because model_name is actually an ActiveModel::Name
|
39
|
+
# and that can't be serialized by Rubinius. (Worked fine with all other rubies, though...)
|
40
|
+
self.id = File.join(model_name.to_s, connection.incr("__uniq__").to_s)
|
39
41
|
end
|
40
42
|
|
41
43
|
module ClassMethods
|
data/lib/redis/orm/version.rb
CHANGED
data/redis-orm.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_development_dependency 'rspec', '~> 2.6.0'
|
22
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
23
|
+
s.add_development_dependency 'bundler', '~> 1.0.18'
|
22
24
|
|
23
25
|
s.add_runtime_dependency 'redis', '~> 2.2.2'
|
24
26
|
s.add_runtime_dependency 'activemodel', '~> 3.0.10'
|
@@ -13,6 +13,10 @@ describe Redis::Actions::Finding do
|
|
13
13
|
it "should find all of them" do
|
14
14
|
all = orm_class.all
|
15
15
|
all.length.should == 10
|
16
|
+
|
17
|
+
# we must sort due to hashes being unordered in Ruby 1.8
|
18
|
+
all = all.sort { |a, b| a.random <=> b.random }
|
19
|
+
|
16
20
|
10.times { |i| all[i].random.should == i }
|
17
21
|
end
|
18
22
|
end
|
data/test.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: redis-orm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Colin MacKenzie IV
|
@@ -24,27 +24,49 @@ dependencies:
|
|
24
24
|
type: :development
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: rake
|
28
28
|
prerelease: false
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.9.2
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.18
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: redis
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
30
52
|
none: false
|
31
53
|
requirements:
|
32
54
|
- - ~>
|
33
55
|
- !ruby/object:Gem::Version
|
34
56
|
version: 2.2.2
|
35
57
|
type: :runtime
|
36
|
-
version_requirements: *
|
58
|
+
version_requirements: *id004
|
37
59
|
- !ruby/object:Gem::Dependency
|
38
60
|
name: activemodel
|
39
61
|
prerelease: false
|
40
|
-
requirement: &
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
41
63
|
none: false
|
42
64
|
requirements:
|
43
65
|
- - ~>
|
44
66
|
- !ruby/object:Gem::Version
|
45
67
|
version: 3.0.10
|
46
68
|
type: :runtime
|
47
|
-
version_requirements: *
|
69
|
+
version_requirements: *id005
|
48
70
|
description: The goal of this project is to provide ORM for Redis that feels very similar to ActiveRecord.
|
49
71
|
email:
|
50
72
|
- sinisterchipmunk@gmail.com
|
@@ -56,6 +78,7 @@ extra_rdoc_files: []
|
|
56
78
|
|
57
79
|
files:
|
58
80
|
- .gitignore
|
81
|
+
- .travis.yml
|
59
82
|
- Gemfile
|
60
83
|
- README.md
|
61
84
|
- Rakefile
|