repositor 0.3.4 → 0.4.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: 34230c2618bdb2c0f7d17f517000ae84da73495e
4
- data.tar.gz: f9d5333f56482b6a78d3f1af5fa0d5882452d776
3
+ metadata.gz: 57ecdac0dba23e52a2837a0a56185f999b873d90
4
+ data.tar.gz: bf29c856e21fd9c84edb64114646164f350ce5d9
5
5
  SHA512:
6
- metadata.gz: 00a375c71ca19cf02ae51de1f073e9df936269e0e2714b1f5f124c741c59731d5c646807f3052af3f22b93d51c0ddebfc2799a456b6f6e9e19f79d8bbcb7f2e2
7
- data.tar.gz: 2a0f5280f3326f768cca2cd8091d948268d606a1edcc85fe718385f433473c9aff3ebb5c0cf0500ba5604e01396ce6fa475f8d21880e5c3b00838ffca901aa9d
6
+ metadata.gz: ffa9d513e8a76ac0d87c87b61919d094f452445182b6c6b1e90362efe5438afc9b4adf71284e10960c0f7ad6e3dd78989525479f84699dad48f17799a7eba58e
7
+ data.tar.gz: d41b29977d2bb2756f1464c82f9d799fb2d6d9ca5928b800128eb56baae17dca509ecb3acaf8ccd4a2ce32406af9d81529bfb8e297d0b8d52f48d0fa0f94d54d
data/README.md CHANGED
@@ -101,7 +101,7 @@ In `app` directory you need to create new `repos` directory . Recomended to crea
101
101
  class ApplicationRepo
102
102
  # include ORM submodule
103
103
  # now supported only ActiveRecord
104
- # more will added soon
104
+ # more will be added soon
105
105
  include Repositor::ActiveRecord
106
106
  end
107
107
  ```
@@ -110,6 +110,11 @@ Than you need to create `products_repo.rb`:
110
110
  ```ruby
111
111
  class ProductsRepo < ApplicationRepo
112
112
  # here you will have default methods for repo actions
113
+ # if you want communicate with model class,
114
+ # just can use model method to send it any method you need
115
+ def all_with_name_john
116
+ model.where(name: 'John')
117
+ end
113
118
  end
114
119
  ```
115
120
  and that's all... magic already happened (no)
@@ -119,18 +124,22 @@ If check what exactly was done, including `Repository` module in base `Applicati
119
124
  `Repositor` did for you a lot of dry work. In other case for each repo you must make identical methods, like this:
120
125
  ```ruby
121
126
  class ProductsRepo
122
- def find(product_id)
123
- Product.find(product_id)
124
- end
125
-
126
127
  def all
127
128
  Product.all
128
129
  end
129
130
 
130
- def new
131
+ def new
131
132
  Product.new
132
133
  end
133
134
 
135
+ def find(product_id)
136
+ Product.find(product_id)
137
+ end
138
+
139
+ def create(product_params)
140
+ Product.create(product_params)
141
+ end
142
+
134
143
  def update(product_id, params)
135
144
  find(product_id).tap do |product|
136
145
  product.update(params)
@@ -140,13 +149,10 @@ class ProductsRepo
140
149
  def destroy(product_id)
141
150
  find(product_id).destroy
142
151
  end
143
-
144
- def create(product_params)
145
- Product.create(product_params)
146
- end
147
152
  end
148
153
  ```
149
- If you need to add new method to repo, just define it in repo file.
154
+ If you need to add new method for model, just define it in repo file.
155
+ Keep your model skinny.
150
156
 
151
157
  ## TODO
152
158
  * Specs on the way...
@@ -22,14 +22,12 @@ module Repositor
22
22
  model.send :create, record_params
23
23
  end
24
24
 
25
- def update(record_id, record_params)
26
- find(record_id).tap do |record|
27
- record.update(record_params)
28
- end
25
+ def update(record, record_params)
26
+ record.update(record_params)
29
27
  end
30
28
 
31
- def destroy(record_id)
32
- find(record_id).destroy
29
+ def destroy(record)
30
+ record.destroy
33
31
  end
34
32
  end
35
33
  end
data/lib/repositor.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'repositor/active_record'
2
+ require 'active_support/inflector'
2
3
 
3
4
  module Repositor
4
5
  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.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volodya Sveredyuk
@@ -30,6 +30,40 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.4.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: pry
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.10.3
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.10.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: activesupport
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '4.2'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 4.2.6
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '4.2'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 4.2.6
33
67
  description: Create simple Repos for Rails Controllers
34
68
  email: sveredyuk@gmail.com
35
69
  executables: []