get 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -3
- data/lib/get/builders/ancestry_builder.rb +1 -1
- data/lib/get/builders/join_builder.rb +1 -1
- data/lib/get/builders/query_builder.rb +1 -1
- data/lib/get/version.rb +3 -0
- data/lib/get.rb +4 -5
- data/spec/get_spec.rb +43 -82
- metadata +29 -44
- data/lib/get/configuration.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24209f31c15fd914e951892e126bd82340ed89a9
|
4
|
+
data.tar.gz: edbda8c1b863295e0caa8d593fc6e4cb73be3008
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdaa750abb6815f38de23fe6813b77f1f99cad718f27a7fe6abf5a28a1aea3e520316990c1f9b984c28c5a1c672398224966adda2b48f62ff315aeef825dfd14
|
7
|
+
data.tar.gz: 168495d26ce9cb4538a3869d11be9fa76fef286133ad9c6f6ab1a23a6276f9228b56d857227ad57ce7f541a37875c087e7671f5a42af9c5394eb8b6cf82e1004
|
data/README.md
CHANGED
@@ -33,6 +33,11 @@ With Options
|
|
33
33
|
Get::UsersByLastName.run('Turner', limit: 10, offset: 20, order: { last_name: :desc })
|
34
34
|
```
|
35
35
|
|
36
|
+
All records
|
37
|
+
```ruby
|
38
|
+
Get::AllUsers.run
|
39
|
+
```
|
40
|
+
|
36
41
|
#### Associations
|
37
42
|
|
38
43
|
Associations use 'From', and are sugar for the chains we so often write in rails.
|
@@ -309,19 +314,21 @@ end
|
|
309
314
|
By encapsulating the query in a class, we're able to stub it at the class level, which eliminates then need to create any dependencies.
|
310
315
|
This will speed up tests (a little), but more importantly it makes them easier to read and write.
|
311
316
|
|
317
|
+
|
312
318
|
## Config
|
319
|
+
<tt>Get</tt> uses the underlying Horza configuration, so all configuration options can be set on <tt>Get</tt> just like they would on <tt>Horza</tt>.
|
313
320
|
|
314
|
-
|
321
|
+
***e.g. Defining your adapter***
|
315
322
|
|
316
323
|
_config/initializers/get.rb_
|
317
324
|
```ruby
|
318
325
|
Get.configure { |config| config.adapter = :active_record }
|
319
326
|
```
|
320
|
-
|
327
|
+
For more details on configuration check out the <tt>Horza</tt> [documentation.](https://github.com/onfido/horza)
|
321
328
|
|
322
329
|
## Adapters
|
323
330
|
|
324
|
-
Get currently works with ActiveRecord.
|
331
|
+
Get currently only works with ActiveRecord.
|
325
332
|
|
326
333
|
## Edge Cases
|
327
334
|
|
@@ -8,7 +8,7 @@ module Get
|
|
8
8
|
key: @key,
|
9
9
|
collection: @result_entity.plural?,
|
10
10
|
result_entity: @result_entity.singularize.symbolize,
|
11
|
-
store: Get.adapter.context_for_entity(@result_entity.singularize
|
11
|
+
store: Get.adapter.context_for_entity(@result_entity.singularize)
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
data/lib/get/version.rb
ADDED
data/lib/get.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
|
+
require 'horza'
|
1
2
|
require 'get/builders/base_builder'
|
2
3
|
require 'get/builders/ancestry_builder'
|
3
4
|
require 'get/builders/query_builder'
|
4
5
|
require 'get/builders/join_builder'
|
5
6
|
require 'get/builders'
|
6
|
-
require 'get/configuration'
|
7
7
|
require 'get/db'
|
8
8
|
require 'get/errors'
|
9
9
|
require 'get/parser'
|
10
10
|
require 'get/run_methods'
|
11
|
-
require '
|
11
|
+
require 'get/version'
|
12
|
+
|
12
13
|
|
13
14
|
module Get
|
14
|
-
extend
|
15
|
+
extend Horza::SharedConfig
|
15
16
|
|
16
17
|
GET_CLASS_REGEX = /^(.*)(By|From)(.*)/
|
17
18
|
|
18
19
|
class << self
|
19
|
-
attr_writer :configuration
|
20
|
-
|
21
20
|
def included(base)
|
22
21
|
base.class_eval do
|
23
22
|
extend ::Get::RunMethods
|
data/spec/get_spec.rb
CHANGED
@@ -13,35 +13,31 @@ else
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
class Employer < ActiveRecord::Base
|
17
|
+
has_many :users
|
18
|
+
has_many :sports_cars
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
class User < ActiveRecord::Base
|
22
|
+
belongs_to :employer
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
25
|
+
class SportsCar < ActiveRecord::Base
|
26
|
+
belongs_to :employer
|
29
27
|
end
|
28
|
+
|
30
29
|
end
|
31
30
|
|
32
31
|
describe Get do
|
33
32
|
let(:last_name) { 'Turner' }
|
34
33
|
let(:adapter) { :active_record }
|
35
34
|
|
36
|
-
# Preserve system config for other tests
|
37
|
-
before(:all) { @system_config = Get.configuration }
|
38
|
-
after(:all) { Get.configuration = @system_config }
|
39
|
-
|
40
35
|
# Reset base config with each iteration
|
41
36
|
before { Get.configure { |config| config.adapter = adapter } }
|
37
|
+
|
42
38
|
after do
|
43
|
-
|
44
|
-
|
39
|
+
User.delete_all
|
40
|
+
Employer.delete_all
|
45
41
|
Get.reset
|
46
42
|
end
|
47
43
|
|
@@ -51,37 +47,6 @@ describe Get do
|
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
54
|
-
context 'development_mode' do
|
55
|
-
before do
|
56
|
-
Get.reset
|
57
|
-
Get.configure do |config|
|
58
|
-
config.adapter = 'my_adapter'
|
59
|
-
config.development_mode = true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
after do
|
63
|
-
Get.reset
|
64
|
-
end
|
65
|
-
it 'sets Horza to development mode' do
|
66
|
-
expect(Horza.configuration.development_mode).to be true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'namespaces' do
|
71
|
-
before do
|
72
|
-
Get.reset
|
73
|
-
Get.configure do |config|
|
74
|
-
config.adapter = 'my_adapter'
|
75
|
-
config.namespaces = [GetSpec]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
after do
|
79
|
-
Get.reset
|
80
|
-
end
|
81
|
-
it 'sets Horza to development mode' do
|
82
|
-
expect(Horza.configuration.namespaces).to eq [GetSpec]
|
83
|
-
end
|
84
|
-
end
|
85
50
|
|
86
51
|
context '#adapter' do
|
87
52
|
context 'when the adapter is set' do
|
@@ -91,31 +56,27 @@ describe Get do
|
|
91
56
|
end
|
92
57
|
|
93
58
|
context 'when the adapter is not set' do
|
94
|
-
before { Get.reset }
|
95
|
-
after { Get.reset }
|
96
|
-
|
97
59
|
it 'throws error' do
|
98
|
-
|
60
|
+
Get.reset
|
61
|
+
expect { Get.adapter }.to raise_error(Horza::Errors::AdapterError)
|
99
62
|
end
|
100
63
|
end
|
101
64
|
end
|
102
65
|
|
103
66
|
context '#reset' do
|
104
67
|
before do
|
105
|
-
Get.configure
|
106
|
-
config.adapter = 'my_adapter'
|
107
|
-
end
|
108
|
-
Get.reset
|
68
|
+
Get.configure { |config| config.constant_paths += ['my_path'] }
|
109
69
|
end
|
110
70
|
it 'resets the config' do
|
111
|
-
|
71
|
+
Get.reset
|
72
|
+
expect(Get.configuration.constant_paths).to be_empty
|
112
73
|
end
|
113
74
|
end
|
114
75
|
|
115
76
|
context '#run!' do
|
116
77
|
context 'singular form' do
|
117
78
|
context 'when the record exists' do
|
118
|
-
let!(:user) {
|
79
|
+
let!(:user) { User.create(last_name: last_name) }
|
119
80
|
|
120
81
|
context 'field in class name' do
|
121
82
|
it 'gets the records based on By[KEY]' do
|
@@ -149,7 +110,7 @@ describe Get do
|
|
149
110
|
|
150
111
|
context 'ancestry' do
|
151
112
|
context 'valid ancestry with no saved parent' do
|
152
|
-
let(:user2) {
|
113
|
+
let(:user2) { User.create }
|
153
114
|
it 'returns nil' do
|
154
115
|
expect(Get::EmployerFromUser.run!(user2)).to be nil
|
155
116
|
end
|
@@ -160,7 +121,7 @@ describe Get do
|
|
160
121
|
context '#run' do
|
161
122
|
context 'singular form' do
|
162
123
|
context 'when the record exists' do
|
163
|
-
let!(:user) {
|
124
|
+
let!(:user) { User.create(last_name: last_name) }
|
164
125
|
|
165
126
|
context 'field in class name' do
|
166
127
|
it 'gets the records based on By[KEY]' do
|
@@ -199,8 +160,8 @@ describe Get do
|
|
199
160
|
|
200
161
|
context 'when records exist' do
|
201
162
|
before do
|
202
|
-
match_count.times {
|
203
|
-
miss_count.times {
|
163
|
+
match_count.times { User.create(last_name: last_name) }
|
164
|
+
miss_count.times { User.create }
|
204
165
|
end
|
205
166
|
|
206
167
|
context 'field in class name' do
|
@@ -243,8 +204,8 @@ describe Get do
|
|
243
204
|
let(:miss_count) { 7 }
|
244
205
|
|
245
206
|
before do
|
246
|
-
match_count.times {
|
247
|
-
miss_count.times {
|
207
|
+
match_count.times { User.create(last_name: last_name) }
|
208
|
+
miss_count.times { User.create }
|
248
209
|
end
|
249
210
|
|
250
211
|
context 'when limit is passed' do
|
@@ -264,7 +225,7 @@ describe Get do
|
|
264
225
|
context 'when order is passed' do
|
265
226
|
it 'orders the response' do
|
266
227
|
result = Get::UsersBy.run({ last_name: last_name }, order: { id: :asc })
|
267
|
-
ar_result =
|
228
|
+
ar_result = User.where(last_name: last_name).order('id asc')
|
268
229
|
|
269
230
|
expect(result.first.id).to eq ar_result.first.id
|
270
231
|
expect(result.last.id).to eq ar_result.last.id
|
@@ -281,9 +242,9 @@ describe Get do
|
|
281
242
|
|
282
243
|
context 'associations' do
|
283
244
|
context 'direct relation' do
|
284
|
-
let(:employer) {
|
285
|
-
let!(:user1) {
|
286
|
-
let!(:user2) {
|
245
|
+
let(:employer) { Employer.create }
|
246
|
+
let!(:user1) { User.create(employer: employer) }
|
247
|
+
let!(:user2) { User.create(employer: employer) }
|
287
248
|
|
288
249
|
context 'ParentFromChild' do
|
289
250
|
it 'returns parent' do
|
@@ -294,7 +255,7 @@ describe Get do
|
|
294
255
|
context 'ChildrenFromParent' do
|
295
256
|
it 'returns children' do
|
296
257
|
result = Get::UsersFromEmployer.run(employer)
|
297
|
-
ar_result =
|
258
|
+
ar_result = User.where(employer_id: employer.id).order('id desc')
|
298
259
|
expect(result.first.id).to eq ar_result.first.id
|
299
260
|
expect(result.last.id).to eq ar_result.last.id
|
300
261
|
end
|
@@ -307,14 +268,14 @@ describe Get do
|
|
307
268
|
end
|
308
269
|
|
309
270
|
context 'valid ancestry with no saved childred' do
|
310
|
-
let(:employer2) {
|
271
|
+
let(:employer2) { Employer.create }
|
311
272
|
it 'returns empty collection error' do
|
312
273
|
expect(Get::UsersFromEmployer.run(employer2).empty?).to be true
|
313
274
|
end
|
314
275
|
end
|
315
276
|
|
316
277
|
context 'valid ancestry with no saved parent' do
|
317
|
-
let(:user2) {
|
278
|
+
let(:user2) { User.create }
|
318
279
|
it 'returns nil' do
|
319
280
|
expect(Get::EmployerFromUser.run(user2)).to be nil
|
320
281
|
end
|
@@ -322,9 +283,9 @@ describe Get do
|
|
322
283
|
end
|
323
284
|
|
324
285
|
context 'using via' do
|
325
|
-
let(:employer) {
|
326
|
-
let(:user) {
|
327
|
-
let(:sportscar) {
|
286
|
+
let(:employer) { Employer.create }
|
287
|
+
let(:user) { User.create(employer: employer) }
|
288
|
+
let(:sportscar) { SportsCar.create(employer: employer) }
|
328
289
|
|
329
290
|
before do
|
330
291
|
employer.sports_cars << sportscar
|
@@ -342,13 +303,13 @@ describe Get do
|
|
342
303
|
end
|
343
304
|
|
344
305
|
context 'with options' do
|
345
|
-
let(:employer) {
|
306
|
+
let(:employer) { Employer.create }
|
346
307
|
let(:match_count) { 20 }
|
347
308
|
let(:miss_count) { 7 }
|
348
309
|
|
349
310
|
before do
|
350
|
-
match_count.times { employer.users <<
|
351
|
-
miss_count.times { employer.users <<
|
311
|
+
match_count.times { employer.users << User.create(employer: employer, last_name: last_name) }
|
312
|
+
miss_count.times { employer.users << User.create(employer: employer) }
|
352
313
|
end
|
353
314
|
|
354
315
|
context 'when conditions are passed' do
|
@@ -375,7 +336,7 @@ describe Get do
|
|
375
336
|
context 'when order is passed' do
|
376
337
|
it 'orders response' do
|
377
338
|
result = Get::UsersFromEmployer.run(employer.id, conditions: { last_name: last_name }, order: { id: :asc })
|
378
|
-
ar_result =
|
339
|
+
ar_result = User.where(employer_id: employer.id, last_name: last_name).order('id asc')
|
379
340
|
|
380
341
|
expect(result.first.id).to eq ar_result.first.id
|
381
342
|
expect(result.last.id).to eq ar_result.last.id
|
@@ -392,14 +353,14 @@ describe Get do
|
|
392
353
|
end
|
393
354
|
|
394
355
|
context 'joins' do
|
395
|
-
let(:employer) {
|
396
|
-
let(:employer2) {
|
356
|
+
let(:employer) { Employer.create }
|
357
|
+
let(:employer2) { Employer.create }
|
397
358
|
let(:match_count) { 20 }
|
398
359
|
let(:miss_count) { 7 }
|
399
360
|
|
400
361
|
before do
|
401
|
-
match_count.times { employer2.users <<
|
402
|
-
miss_count.times { employer.users <<
|
362
|
+
match_count.times { employer2.users << User.create(employer: employer2) }
|
363
|
+
miss_count.times { employer.users << User.create(employer: employer) }
|
403
364
|
end
|
404
365
|
|
405
366
|
context 'when no conditions are passed' do
|
metadata
CHANGED
@@ -1,111 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Turner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: horza
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activerecord
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.2
|
47
|
+
version: '3.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.2
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: activesupport
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 3.2.15
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 3.2.15
|
54
|
+
version: '3.2'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- -
|
59
|
+
- - '>='
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
61
|
+
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- -
|
66
|
+
- - '>='
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: sqlite3
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- -
|
73
|
+
- - '>='
|
88
74
|
- !ruby/object:Gem::Version
|
89
75
|
version: '0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- -
|
80
|
+
- - '>='
|
95
81
|
- !ruby/object:Gem::Version
|
96
82
|
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: byebug
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - '>='
|
102
88
|
- !ruby/object:Gem::Version
|
103
89
|
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- -
|
94
|
+
- - '>='
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
description: Encapsulate your database queries with dynamically generated classes
|
@@ -114,19 +100,19 @@ executables: []
|
|
114
100
|
extensions: []
|
115
101
|
extra_rdoc_files: []
|
116
102
|
files:
|
117
|
-
- LICENSE.txt
|
118
|
-
- README.md
|
119
|
-
- lib/get.rb
|
120
|
-
- lib/get/builders.rb
|
121
103
|
- lib/get/builders/ancestry_builder.rb
|
122
104
|
- lib/get/builders/base_builder.rb
|
123
105
|
- lib/get/builders/join_builder.rb
|
124
106
|
- lib/get/builders/query_builder.rb
|
125
|
-
- lib/get/
|
107
|
+
- lib/get/builders.rb
|
126
108
|
- lib/get/db.rb
|
127
109
|
- lib/get/errors.rb
|
128
110
|
- lib/get/parser.rb
|
129
111
|
- lib/get/run_methods.rb
|
112
|
+
- lib/get/version.rb
|
113
|
+
- lib/get.rb
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
130
116
|
- spec/get_spec.rb
|
131
117
|
- spec/spec_helper.rb
|
132
118
|
homepage: https://github.com/BlakeTurner/get
|
@@ -139,22 +125,21 @@ require_paths:
|
|
139
125
|
- lib
|
140
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
127
|
requirements:
|
142
|
-
- -
|
128
|
+
- - '>='
|
143
129
|
- !ruby/object:Gem::Version
|
144
130
|
version: '0'
|
145
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
132
|
requirements:
|
147
|
-
- -
|
133
|
+
- - '>='
|
148
134
|
- !ruby/object:Gem::Version
|
149
135
|
version: '0'
|
150
136
|
requirements: []
|
151
137
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.0.14
|
153
139
|
signing_key:
|
154
140
|
specification_version: 4
|
155
141
|
summary: Get is a library designed to encapsulate Rails database queries and prevent
|
156
142
|
query pollution in the view layer.
|
157
143
|
test_files:
|
158
|
-
- spec/spec_helper.rb
|
159
144
|
- spec/get_spec.rb
|
160
|
-
|
145
|
+
- spec/spec_helper.rb
|
data/lib/get/configuration.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Get
|
2
|
-
module Configuration
|
3
|
-
def configuration
|
4
|
-
@configuration ||= Config.new
|
5
|
-
end
|
6
|
-
|
7
|
-
def reset
|
8
|
-
@configuration = Config.new
|
9
|
-
@adapter, @adapter_map = nil, nil # Class-level cache clear
|
10
|
-
end
|
11
|
-
|
12
|
-
def configure
|
13
|
-
yield(configuration)
|
14
|
-
end
|
15
|
-
|
16
|
-
def adapter
|
17
|
-
raise ::Get::Errors::Base.new('Adapter has not been configured') unless configuration.adapter
|
18
|
-
@adapter ||= configuration.adapter
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Config
|
23
|
-
attr_accessor :adapter, :environment
|
24
|
-
|
25
|
-
def adapter=(adapter)
|
26
|
-
Horza.configure { |config| config.adapter = adapter }
|
27
|
-
@adapter = Horza.adapter
|
28
|
-
end
|
29
|
-
|
30
|
-
def development_mode=(mode)
|
31
|
-
Horza.configure { |config| config.development_mode = mode }
|
32
|
-
end
|
33
|
-
|
34
|
-
def namespaces=(namespaces)
|
35
|
-
raise ::Get::Errors::Base.new('namespaces must be an array') unless namespaces.is_a? Array
|
36
|
-
Horza.configure { |config| config.namespaces = namespaces }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|