redpear 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redpear/model.rb +17 -1
- data/lib/redpear/persistence.rb +2 -0
- metadata +16 -27
data/lib/redpear/model.rb
CHANGED
@@ -44,13 +44,21 @@ class Redpear::Model < Hash
|
|
44
44
|
update(attrs)
|
45
45
|
end
|
46
46
|
|
47
|
-
#
|
47
|
+
# Returns the ID of the record
|
48
|
+
# @return [String]
|
48
49
|
def id
|
49
50
|
value = __fetch__("id")
|
50
51
|
value.to_s if value
|
51
52
|
end
|
52
53
|
|
54
|
+
# ID accessor
|
55
|
+
# @param [Object] id
|
56
|
+
def id=(value)
|
57
|
+
self["id"] = value.to_s
|
58
|
+
end
|
59
|
+
|
53
60
|
# Custom comparator
|
61
|
+
# @return [Boolean]
|
54
62
|
def ==(other)
|
55
63
|
case other
|
56
64
|
when Redpear::Model
|
@@ -61,6 +69,7 @@ class Redpear::Model < Hash
|
|
61
69
|
end
|
62
70
|
|
63
71
|
# Attribute reader with type-casting
|
72
|
+
# @return [Object]
|
64
73
|
def [](name)
|
65
74
|
__ensure_loaded__
|
66
75
|
name = name.to_s
|
@@ -72,6 +81,8 @@ class Redpear::Model < Hash
|
|
72
81
|
end
|
73
82
|
|
74
83
|
# Attribute writer
|
84
|
+
# @param [String] name
|
85
|
+
# @param [Object] value
|
75
86
|
def []=(name, value)
|
76
87
|
__ensure_loaded__
|
77
88
|
name = name.to_s
|
@@ -80,6 +91,9 @@ class Redpear::Model < Hash
|
|
80
91
|
end
|
81
92
|
|
82
93
|
# Returns a Hash with attributes
|
94
|
+
# @param [Boolean] clean
|
95
|
+
# If true, only actual values will be returned (without nils), defaults to false
|
96
|
+
# @return [Hash]
|
83
97
|
def to_hash(clean = false)
|
84
98
|
__ensure_loaded__
|
85
99
|
attrs = clean ? reject {|_, v| v.nil? } : self
|
@@ -87,12 +101,14 @@ class Redpear::Model < Hash
|
|
87
101
|
end
|
88
102
|
|
89
103
|
# Show information about this record
|
104
|
+
# @return [String]
|
90
105
|
def inspect
|
91
106
|
__ensure_loaded__
|
92
107
|
"#<#{self.class.name} #{super}>"
|
93
108
|
end
|
94
109
|
|
95
110
|
# Bulk-update attributes
|
111
|
+
# @param [Hash] attrs
|
96
112
|
def update(attrs)
|
97
113
|
attrs = (attrs ? attrs.stringify_keys : {})
|
98
114
|
attrs["id"] = attrs["id"].to_s if attrs["id"]
|
data/lib/redpear/persistence.rb
CHANGED
@@ -18,6 +18,7 @@ module Redpear::Persistence
|
|
18
18
|
def save(*args)
|
19
19
|
new(*args).tap(&:save)
|
20
20
|
end
|
21
|
+
alias_method :save!, :save
|
21
22
|
|
22
23
|
# Destroys a record. Example:
|
23
24
|
# @param id the ID of the record to destroy
|
@@ -75,6 +76,7 @@ module Redpear::Persistence
|
|
75
76
|
ensure
|
76
77
|
after_save
|
77
78
|
end
|
79
|
+
alias_method :save!, :save
|
78
80
|
|
79
81
|
# Destroy the record.
|
80
82
|
# @return [Boolean] true or false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redpear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-02 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &16033840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16033840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nest
|
27
|
-
requirement: &
|
27
|
+
requirement: &16033380 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.1.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16033380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &16033000 !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: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *16033000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &16062160 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *16062160
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &16061740 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *16061740
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeredis
|
71
|
-
requirement: &
|
71
|
+
requirement: &16061320 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *16061320
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: shoulda-matchers
|
82
|
-
requirement: &
|
82
|
+
requirement: &16060900 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,18 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: machinist
|
93
|
-
requirement: &20065820 !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
|
-
requirements:
|
96
|
-
- - ~>
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 2.0.0.beta
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: *20065820
|
90
|
+
version_requirements: *16060900
|
102
91
|
description: Simple, elegant & efficient ORM for Redis
|
103
92
|
email: dimitrij@blacksquaremedia.com
|
104
93
|
executables: []
|