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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea3d77e6eeb067afcc25a332a4015f9aca9d6d7b
4
- data.tar.gz: 71763f7bc14e48b1f76ff63eb990dade3d3188a1
3
+ metadata.gz: 2f4d2dc0aac3e0ef6c38108d0859b2bab0697d78
4
+ data.tar.gz: 7d377f9f7d020d6f681dfb398e5841bf2a206ffa
5
5
  SHA512:
6
- metadata.gz: 5bb4ee56e0366cc6e8aac6f3a7e61a7294e09c4319bd0647ce384882dfb0842fb81ec4a9cf63643bacd04eea91cc49ce90f871e5a811ced18e1c24ac63dcb13c
7
- data.tar.gz: a4207c6188f7c453600014dc054ee1e5ad74c0ebf93a886745084f0e61ff7987973cddf997f046080f29346f64624a2624e78ace1f2742f0c3675f3222e24697
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
- 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. That's all. No magic.
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repositor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk