looksy 0.0.6 → 0.0.8
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.
data/lib/looksy.rb
CHANGED
data/lib/looksy/cacheable.rb
CHANGED
@@ -30,25 +30,25 @@ module Looksy
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def fetch_all
|
33
|
-
|
33
|
+
repository.all
|
34
34
|
end
|
35
35
|
|
36
36
|
def fetch_first
|
37
|
-
|
37
|
+
repository.first
|
38
38
|
end
|
39
39
|
|
40
40
|
def fetch_last
|
41
|
-
|
41
|
+
repository.last
|
42
42
|
end
|
43
43
|
|
44
44
|
def fetch_by_id(id)
|
45
|
-
|
45
|
+
repository.find_by_id(id)
|
46
46
|
end
|
47
47
|
|
48
48
|
def method_missing(method, *args, &block)
|
49
49
|
if method.match(/^fetch/)
|
50
50
|
method = method.to_s.gsub(/^fetch/, 'find')
|
51
|
-
|
51
|
+
repository.send(method, *args, &block)
|
52
52
|
else
|
53
53
|
super
|
54
54
|
end
|
@@ -56,8 +56,8 @@ module Looksy
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
-
def
|
60
|
-
@
|
59
|
+
def repository
|
60
|
+
@repository ||= Looksy::Repository.new(self, cache_store)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Looksy
|
2
|
-
class
|
2
|
+
class Repository
|
3
3
|
def initialize(klass, cache)
|
4
4
|
@klass = klass
|
5
5
|
@cache = cache
|
@@ -9,11 +9,11 @@ module Looksy
|
|
9
9
|
@cache.fetch(@klass.cache_key, @klass.cache_options) { @klass.all }
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def first
|
13
13
|
all.first
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def last
|
17
17
|
all.last
|
18
18
|
end
|
19
19
|
|
data/lib/looksy/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "support/record"
|
3
3
|
|
4
|
-
describe Looksy::
|
4
|
+
describe Looksy::Repository do
|
5
5
|
let(:klass) { Record }
|
6
6
|
let(:cache) { Looksy::NullCache.new }
|
7
|
-
let(:lookup) { Looksy::
|
7
|
+
let(:lookup) { Looksy::Repository.new(klass, cache) }
|
8
8
|
|
9
9
|
describe '#all' do
|
10
10
|
it 'retrieves all records' do
|
@@ -12,15 +12,15 @@ describe Looksy::Lookup do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe '#
|
15
|
+
describe '#first' do
|
16
16
|
it 'retrieves the first record' do
|
17
|
-
lookup.
|
17
|
+
lookup.first.should eql(klass.first)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe '#
|
21
|
+
describe '#last' do
|
22
22
|
it 'retrieves the last record' do
|
23
|
-
lookup.
|
23
|
+
lookup.last.should eql(klass.last)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: looksy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
requirement: &
|
17
|
+
requirement: &53734640 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *53734640
|
26
26
|
description: Add a caching layer to your ActiveRecord models that represent look up
|
27
27
|
tables
|
28
28
|
email:
|
@@ -40,13 +40,13 @@ files:
|
|
40
40
|
- lib/looksy.rb
|
41
41
|
- lib/looksy/cacheable.rb
|
42
42
|
- lib/looksy/dynamic_find_match.rb
|
43
|
-
- lib/looksy/lookup.rb
|
44
43
|
- lib/looksy/null_cache.rb
|
44
|
+
- lib/looksy/repository.rb
|
45
45
|
- lib/looksy/version.rb
|
46
46
|
- looksy.gemspec
|
47
47
|
- spec/lib/cacheable_spec.rb
|
48
48
|
- spec/lib/dynamic_find_match_spec.rb
|
49
|
-
- spec/lib/
|
49
|
+
- spec/lib/repository_spec.rb
|
50
50
|
- spec/spec_helper.rb
|
51
51
|
- spec/support/record.rb
|
52
52
|
has_rdoc: true
|
@@ -77,6 +77,6 @@ summary: Caching layer for look up tables
|
|
77
77
|
test_files:
|
78
78
|
- spec/lib/cacheable_spec.rb
|
79
79
|
- spec/lib/dynamic_find_match_spec.rb
|
80
|
-
- spec/lib/
|
80
|
+
- spec/lib/repository_spec.rb
|
81
81
|
- spec/spec_helper.rb
|
82
82
|
- spec/support/record.rb
|