get 0.1.4.2 → 0.1.5.0
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.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/get/errors.rb +3 -0
- data/lib/get/parser.rb +3 -0
- data/spec/get_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35ab11daa222833ce2a9b27474271d07df489689
|
4
|
+
data.tar.gz: 8ef6fe8751908e33a133bc5d99765c3859b77e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4048efdf151cd664d1c6006dd3ea2d10ec901f2c6d08a8b9bb6556f704c9c45b8bc64dd747549ebe0469e7ade6d851b57f78269d146277677271ad36a8a1bf0c
|
7
|
+
data.tar.gz: 2cc06292d2434ae9587187952779ebc8a4861ea2cf3f78be0c028c24c1717d730e92a0943dde2fbd76ee16ee551d1ee55a35eff501f628d3469a2099d1094624
|
data/README.md
CHANGED
@@ -226,6 +226,17 @@ You can reset the config at any time using `Get.reset`.
|
|
226
226
|
|
227
227
|
Get currently works with ActiveRecord.
|
228
228
|
|
229
|
+
## Edge Cases
|
230
|
+
|
231
|
+
Some attributes contain the word 'by', ie. `Customer.invited_by`.
|
232
|
+
Because of the way Get parses classnames, you won't be able to use the attribute-specific format.
|
233
|
+
Use the more general form instead.
|
234
|
+
|
235
|
+
```
|
236
|
+
Get::CustomerByInvitedBy.run('John') #=> throws Get::Errors::InvalidClassName
|
237
|
+
Get::CustomerBy.run(invited_by: 'John') #=> will work
|
238
|
+
```
|
239
|
+
|
229
240
|
## Benchmarking
|
230
241
|
|
231
242
|
Get requests generally run < 1ms slower than ActiveRecord requests.
|
data/lib/get/errors.rb
CHANGED
data/lib/get/parser.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Get
|
2
2
|
class Parser
|
3
3
|
CLASS_REGEX = /^(.*)(By|From)(.*)/
|
4
|
+
CLASS_NAME_BY_ERROR = 'You have multiple instances of "By" in your class. Please use open-ended form ie. Get::UserBy.run(params)'
|
4
5
|
attr_accessor :class_name, :result_entity, :method
|
5
6
|
|
6
7
|
def initialize(class_name)
|
8
|
+
raise Get::Errors::InvalidClassName.new(CLASS_NAME_BY_ERROR) if class_name.to_s.split('By').length > 2
|
9
|
+
|
7
10
|
@class_name = class_name
|
8
11
|
@match = class_name.to_s.match(CLASS_REGEX)
|
9
12
|
@result_entity, @method, @key_string = @match.values_at(1, 2, 3) if @match
|
data/spec/get_spec.rb
CHANGED
@@ -312,6 +312,8 @@ describe Get::Parser do
|
|
312
312
|
let(:query_name) { 'UserFromEmployer' }
|
313
313
|
|
314
314
|
subject { Get::Parser }
|
315
|
+
before { Get.configure { |config| config.set_adapter(:active_record) } }
|
316
|
+
after { Get.reset }
|
315
317
|
|
316
318
|
describe '#match?' do
|
317
319
|
context 'when name is of ancestry type' do
|
@@ -331,6 +333,11 @@ describe Get::Parser do
|
|
331
333
|
expect(subject.new('Blablabla').match?).to be false
|
332
334
|
end
|
333
335
|
end
|
336
|
+
end
|
334
337
|
|
338
|
+
context 'two instances of "By" in class name' do
|
339
|
+
it 'throws error' do
|
340
|
+
expect { subject.new('UserByInvitedByType') }.to raise_error Get::Errors::InvalidClassName
|
341
|
+
end
|
335
342
|
end
|
336
343
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5.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-05-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: horza
|