redismodel 0.1.1 → 0.1.3

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.
Files changed (3) hide show
  1. data/lib/redismodel.rb +6 -3
  2. data/test/benchmarks.rb +8 -3
  3. metadata +2 -2
data/lib/redismodel.rb CHANGED
@@ -47,6 +47,10 @@ class RedisModel
47
47
  @connections[klass.to_s] ||= Redis.new(hash)
48
48
  end
49
49
 
50
+ def self.version
51
+ VERSION
52
+ end
53
+
50
54
 
51
55
  # Casts a object type as a compatible type for redis, or reverses the process.
52
56
  #
@@ -96,7 +100,7 @@ class RedisModel
96
100
  if hash[:id].nil?
97
101
 
98
102
  self.send("id=", generate_uniq_token)
99
- unless self.class.properties[:created_at].nil?
103
+ if self.class.properties.include?(:created_at)
100
104
  set :created_at, DateTime.now
101
105
  end
102
106
  hash.to_a.each do |property|
@@ -271,8 +275,7 @@ class RedisModel
271
275
  value = RedisModel.cast c, value
272
276
  redis.set "#{self.class}:#{id}:#{property}", value
273
277
  @_data[property] = value
274
-
275
- unless property == :updated_at && !self.class.properties[:updated_at].nil?
278
+ unless property == :updated_at || !self.class.properties.include?(:updated_at)
276
279
  set :updated_at, DateTime.now
277
280
  end
278
281
  end
data/test/benchmarks.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'benchmark'
2
- Dir.glob("tests/models/*.rb").each{|f| require f}
2
+ require File.dirname(__FILE__) + '/../lib/redismodel' unless defined? RedisModel
3
+ Dir.glob("test/models/*.rb").each{|f| require f}
4
+
5
+ SIZE = 100
3
6
 
4
7
  Person.destroy_all
5
8
 
@@ -13,9 +16,11 @@ puts Benchmark.measure{
13
16
  end
14
17
  }
15
18
 
16
- puts "Create 1_000 records"
19
+ Person.destroy_all
20
+
21
+ puts "Create #{SIZE} records"
17
22
  puts Benchmark.measure{
18
- 1_000.times do
23
+ SIZE.times do
19
24
  Person.new(
20
25
  :name => "ashley",
21
26
  :age => 18
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ashley Williams