frozen_record 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5d9ab606f1d5e70f62c490272bcee441f11d8b6
4
- data.tar.gz: 96fed4747f8ae0a80c3944defdf9bb69548db474
3
+ metadata.gz: 8ea4f7773d19e5117d8b6f23c0d084f69d9b9536
4
+ data.tar.gz: 55b940e5665ae50fbde6f2a39ea5cd3ef5a441f1
5
5
  SHA512:
6
- metadata.gz: 1a6a86f8a6d46490ccbb0d685f79e1393589609bdfaebcbae59963023b22c21e46cd3011b4dd9baab729b45f16aa4421b19de091f788c8d0a28db5b31b182a42
7
- data.tar.gz: 4b49087f3cf1f2c763d5c79fb533814a18560b1c173f54bd6a5cd9c4cfb1d9b7da82a062d513c3c8b9f692895313a63c0b3e0b76c410ba47dfabcdd1dd5680d5
6
+ metadata.gz: f0bd1f71685d2bac36df3311bf9b8d97697d755eb910a7c7903a64add5543f51b98d975f99813c4c9aa8d2df7c8968f040e28f5478af061469fb964282e06d08
7
+ data.tar.gz: bc8c7766b4100563913f824bd6cb2e95e75439eb8a20cec2ad204195e48b1c8916dc17fcc61f7e9a81a35e0c5b5eef6095477893cf0cd573dc950f1c9a42526f
@@ -18,15 +18,33 @@ module FrozenRecord
18
18
 
19
19
  attribute_method_suffix '?'
20
20
 
21
+ class ThreadSafeStorage
22
+
23
+ def initialize(key)
24
+ @thread_key = key
25
+ end
26
+
27
+ def [](key)
28
+ Thread.current[@thread_key] ||= {}
29
+ Thread.current[@thread_key][key]
30
+ end
31
+
32
+ def []=(key, value)
33
+ Thread.current[@thread_key] ||= {}
34
+ Thread.current[@thread_key][key] = value
35
+ end
36
+
37
+ end
38
+
21
39
  class << self
22
40
 
23
41
  def current_scope
24
- @current_scope ||= Scope.new(self, load_records)
42
+ store[:scope] ||= Scope.new(self, load_records)
25
43
  end
26
44
  alias_method :all, :current_scope
27
45
 
28
46
  def current_scope=(scope)
29
- @current_scope = scope
47
+ store[:scope] = scope
30
48
  end
31
49
 
32
50
  delegate :find, :find_by_id, :where, :first, :first!, :last, :last!, :pluck, :order, :limit, :offset,
@@ -45,6 +63,10 @@ module FrozenRecord
45
63
 
46
64
  private
47
65
 
66
+ def store
67
+ @store = ThreadSafeStorage.new(name)
68
+ end
69
+
48
70
  def method_missing(name, *args)
49
71
  if name.to_s =~ FIND_BY_PATTERN
50
72
  return dynamic_match($1, args, $2.present?)
@@ -1,3 +1,3 @@
1
1
  module FrozenRecord
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frozen_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel