sandra 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sandra/key_validator.rb +11 -0
- data/lib/sandra/list.rb +19 -0
- data/lib/sandra/uniqueness_validator.rb +0 -0
- metadata +12 -9
@@ -0,0 +1,11 @@
|
|
1
|
+
module Sandra
|
2
|
+
class KeyValidator < ActiveModel::EachValidator
|
3
|
+
def validate_each(record, attribute, value)
|
4
|
+
if record.attributes[attribute.to_s].nil?
|
5
|
+
record.errors[attribute] << "#{attribute.to_s} cannot be nil."
|
6
|
+
else
|
7
|
+
record.errors[attribute] << "#{record.attributes[attribute.to_s]} has been taken." if record.new_record? && record.class.get(record.attributes[attribute.to_s])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/sandra/list.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Sandra
|
2
|
+
class List
|
3
|
+
def initialize(name, type, owner)
|
4
|
+
@column_family = name.to_s.camelize
|
5
|
+
@type = type.to_s.constantize
|
6
|
+
@owner = owner
|
7
|
+
|
8
|
+
keys = @type.connection.get(@column_family, @owner.key).keys
|
9
|
+
@elements = @type.multi_get(keys)
|
10
|
+
end
|
11
|
+
|
12
|
+
def <<(obj)
|
13
|
+
if obj.is_a?(@type)
|
14
|
+
@elements << obj
|
15
|
+
@type.connection.insert(@column_family, @owner.key, {obj.key => Time.now.to_s})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2010-08-08 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thrift_client
|
16
|
-
requirement: &
|
16
|
+
requirement: &70095423094380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.8.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70095423094380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: cassandra
|
27
|
-
requirement: &
|
27
|
+
requirement: &70095423093940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70095423093940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activemodel
|
38
|
-
requirement: &
|
38
|
+
requirement: &70095423093480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70095423093480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70095423093000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70095423093000
|
58
58
|
description: Provides an Object Relational interface to Cassandra
|
59
59
|
email: chuck@teachmetocode.com
|
60
60
|
executables: []
|
@@ -64,6 +64,9 @@ files:
|
|
64
64
|
- README
|
65
65
|
- MIT-LICENSE
|
66
66
|
- lib/sandra.rb
|
67
|
+
- lib/sandra/list.rb
|
68
|
+
- lib/sandra/key_validator.rb
|
69
|
+
- lib/sandra/uniqueness_validator.rb
|
67
70
|
homepage: http://teachmetocode.com/
|
68
71
|
licenses: []
|
69
72
|
post_install_message:
|