repositorish 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/repositorish.rb +7 -3
- data/lib/repositorish/version.rb +1 -1
- data/spec/integration/active_record_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzFkMTE4MmZjMDkwZDYyNTcwNDc0NjczMTBjZDRjZjhmYzRhNTdkYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2E0Y2IyZGE5YmYxNzEzYjFjYmFkMGQwZThlZmFiMGEyZWI4YWZmYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDkxZDNhZDlhZWM3ZTMzZGY5ODQ1Y2Q4OWFjYWFjN2JjMmRjNDNlOTU5ZmQx
|
10
|
+
YjhiNzNlYzkyNGZiZjcyOTBjZWNlZDY1YmNmMzg3MzM3NDQyZmQzOWM1NzU2
|
11
|
+
MzNmNTVlNTAyZDYwYmZiOTMxODRmODY2ZDZhMmY4MzA2ODE1OTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDYwZjg5NzNmNjBmOGE0MGUwYjk3Yjk4OGNiMWU1ZjI0YjEzODBjZTg1Yjhi
|
14
|
+
YWY3NDlhZTIwOTcwODZhZTY4NzY0ZTU2Y2RiYzgxNzhjMDA4OGIyMjBiNTI3
|
15
|
+
MGMxZjJlZmY3MDZhNWZhYjcyODNlYWFiY2ZmYWU0NDdlYjk2N2M=
|
data/lib/repositorish.rb
CHANGED
@@ -21,8 +21,8 @@ require 'repositorish/version'
|
|
21
21
|
# # => <User::ActiveRecord_Relation ...>
|
22
22
|
# ```
|
23
23
|
module Repositorish
|
24
|
-
CHAINABLE_NAMESPACES = %w(ActiveRecord ActiveRecord_Relation ActiveRecord_AssociationRelation)
|
25
|
-
CHAINABLE_NAMESPACES_REGEX = /(?:^|::)(?:#{CHAINABLE_NAMESPACES.join('|')})(?:$|::)
|
24
|
+
CHAINABLE_NAMESPACES = %w(ActiveRecord ActiveRecord_Relation ActiveRecord_AssociationRelation).freeze
|
25
|
+
CHAINABLE_NAMESPACES_REGEX = /(?:^|::)(?:#{CHAINABLE_NAMESPACES.join('|')})(?:$|::)/
|
26
26
|
|
27
27
|
def self.included(base)
|
28
28
|
base.send :extend, ClassMethods
|
@@ -60,6 +60,10 @@ module Repositorish
|
|
60
60
|
domain.class == @domain.class
|
61
61
|
end
|
62
62
|
|
63
|
+
def respond_to_missing?(method_name, include_private = false)
|
64
|
+
domain.respond_to?(method_name) || super
|
65
|
+
end
|
66
|
+
|
63
67
|
# :nodoc:
|
64
68
|
module ClassMethods
|
65
69
|
def repositorish(model, options = {})
|
@@ -93,7 +97,7 @@ module Repositorish
|
|
93
97
|
def method_missing(method, *args, &block)
|
94
98
|
return query.public_send(method, *args, &block) if method_defined?(method)
|
95
99
|
|
96
|
-
|
100
|
+
raise DomainMethodError, method if @domain.respond_to?(method)
|
97
101
|
super
|
98
102
|
end
|
99
103
|
end
|
data/lib/repositorish/version.rb
CHANGED
@@ -63,6 +63,7 @@ RSpec.describe 'ActiveRecord integration' do
|
|
63
63
|
mary = User.create(name: 'Mary', last_sign_in_at: 1.day.ago, confirmed_at: 2.day.ago)
|
64
64
|
john = User.create(name: 'John', last_sign_in_at: 2.week.ago, confirmed_at: 1.month.ago)
|
65
65
|
|
66
|
+
expect(UserRepository.active).to respond_to(:count)
|
66
67
|
expect(UserRepository.confirmed).to contain_exactly(john, mary)
|
67
68
|
expect(UserRepository.active).to contain_exactly(mary)
|
68
69
|
end
|