repositor 0.5.0 → 0.6.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 +13 -2
- data/lib/repositor/active_record.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f4d2dc0aac3e0ef6c38108d0859b2bab0697d78
|
4
|
+
data.tar.gz: 7d377f9f7d020d6f681dfb398e5841bf2a206ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a08fd436d801cc60b8933f987539843bf3251da8bd6a4f35bf89c57599360c74df803ed2cc948db2da18bc76f20e1f7df8185b53db4030d97fff73c254f84e27
|
7
|
+
data.tar.gz: b2a3c3e53ab6241a0f3981c07756e4c7931e165f933a036ae75874d454ae469f28391446127848a94b08804214e955d2673b411e84febbe795a9e8f759b3e208
|
data/README.md
CHANGED
@@ -118,9 +118,20 @@ class ProductRepo < ApplicationRepo
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
```
|
121
|
-
and that's all... magic already happened (no)
|
122
121
|
|
123
|
-
|
122
|
+
Also `Repositor` will redirect all missing methods to instance if it was passed as first argument:
|
123
|
+
```ruby
|
124
|
+
product_repo.new_record?(product)
|
125
|
+
```
|
126
|
+
same as:
|
127
|
+
```ruby
|
128
|
+
product.new_record?
|
129
|
+
```
|
130
|
+
Only with the reason that you are not linked with data, only with it repo.
|
131
|
+
|
132
|
+
and that's all...
|
133
|
+
|
134
|
+
If check what exactly was done, including `Repository` module in base `ApplicationRepo` will add default CRUD methods to all repos that will be inherited from it.
|
124
135
|
|
125
136
|
`Repositor` did for you a lot of dry work. In other case for each repo you must make identical methods, like this:
|
126
137
|
```ruby
|
@@ -30,5 +30,15 @@ module Repositor
|
|
30
30
|
def destroy(record)
|
31
31
|
record.destroy
|
32
32
|
end
|
33
|
+
|
34
|
+
def method_missing(method, *args)
|
35
|
+
return unless args[0].instance_of? model
|
36
|
+
|
37
|
+
unless args.drop(1).empty?
|
38
|
+
args[0].send(method, args.drop(1))
|
39
|
+
else
|
40
|
+
args[0].send(method)
|
41
|
+
end
|
42
|
+
end
|
33
43
|
end
|
34
44
|
end
|