golden-objects 0.3.0 → 0.3.1
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/CHANGELOG.md +7 -3
- data/README.md +27 -9
- data/lib/golden/objects/query/query_form_operator.rb +1 -1
- data/lib/golden/objects/query/query_result_presenter.rb +1 -1
- data/lib/golden/objects/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ad698392e6eec0c07e6dad7191d9e05de80cbbc748d89e4a4ade15abbc1268b
|
4
|
+
data.tar.gz: 03015a5526edc2b9d9b8e7369b29c37693768baa323e0d596ad8b9bf134d0209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ede8e78272efa09a5a0901b9f17ad797fcb52b88c7286ae374fe1cd737de4655496a829453ffe1879b12be4ae280ef039778875a590ae258b24d4a5fc209910
|
7
|
+
data.tar.gz: d542dffaeae9c5f6825727de69621b50124d04b5a67eb0078502480077ded2ce3fd8bf3f7d9f4e1029d7c1411f2605a9deda028426a295b1f88d84042e6bf304
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Change Logs
|
2
2
|
|
3
|
-
|
3
|
+
## v0.3.1
|
4
|
+
|
5
|
+
* The argement `presenter_class` of `Golden::QueryResultPresenter.collect` should be string instead of class.
|
6
|
+
|
7
|
+
## v0.3.0
|
4
8
|
|
5
9
|
* `Golden::QueryResultPresenter`:
|
6
10
|
* BREAKING: Change `initialize` definition.
|
@@ -15,11 +19,11 @@
|
|
15
19
|
* Include `ActiveRecord::Sanitization::ClassMethods`.
|
16
20
|
* Change prefered `sort` implementation.
|
17
21
|
|
18
|
-
|
22
|
+
## v0.2.0
|
19
23
|
|
20
24
|
* Add golden form builder and helper
|
21
25
|
* Golden query context support pluck
|
22
26
|
|
23
|
-
|
27
|
+
## v0.1.0
|
24
28
|
|
25
29
|
* Initial release.
|
data/README.md
CHANGED
@@ -8,32 +8,49 @@ Let's compose business logics as ruby components to improve efficiency of mainte
|
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
|
-
```ruby
|
11
|
+
``` ruby
|
12
12
|
gem 'golden-objects'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
17
|
-
|
17
|
+
``` shell
|
18
|
+
bundle install
|
19
|
+
```
|
18
20
|
|
19
21
|
Or install it yourself as:
|
20
22
|
|
21
|
-
|
23
|
+
``` shell
|
24
|
+
gem install golden-objects
|
25
|
+
```
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
29
|
Create your class and inherite appropriate golden object directly or though another class.
|
26
30
|
|
27
|
-
```
|
31
|
+
``` ruby
|
28
32
|
class ApplicationPresenter < Golden::ApplicationPresenter
|
29
33
|
include Rails.application.routes.url_helpers
|
30
34
|
end
|
31
35
|
|
36
|
+
class CartLineItemPresenter < ApplicationPresenter
|
37
|
+
class << self
|
38
|
+
def collect(records)
|
39
|
+
::Golden::QueryResultPresenter.collect(records, name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(line_item, accessors = {})
|
44
|
+
super(accessors)
|
45
|
+
@line_item = line_item
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
32
49
|
class CartPresenter < ApplicationPresenter
|
33
50
|
attr_accessor :product_variants
|
34
51
|
|
35
52
|
def line_items_presenter
|
36
|
-
@line_items_presenter ||= CartLineItemPresenter.
|
53
|
+
@line_items_presenter ||= CartLineItemPresenter.collect(product_variants)
|
37
54
|
end
|
38
55
|
end
|
39
56
|
```
|
@@ -45,14 +62,14 @@ And put into suggested pathes.
|
|
45
62
|
|
46
63
|
Grouping classes by multi layers of folders are also suggested.
|
47
64
|
|
48
|
-
```
|
65
|
+
``` shell
|
49
66
|
app/components/[major business logic]/[secondary business logic]/xxx_xxx.rb
|
50
67
|
app/objects/[major data model logic]/[secondary data model logic]/xxx_xxx.rb
|
51
68
|
```
|
52
69
|
|
53
70
|
For example:
|
54
71
|
|
55
|
-
```
|
72
|
+
``` shell
|
56
73
|
app/components/identity/profile/update_form.rb
|
57
74
|
app/components/frontend/popup_cart/main_presenter.rb
|
58
75
|
app/objects/orders/line_item/create_operator.rb
|
@@ -95,11 +112,12 @@ app/objects/orders/create_operator.rb
|
|
95
112
|
|
96
113
|
require extension for actionview in controller of rails.
|
97
114
|
|
98
|
-
```
|
115
|
+
``` ruby
|
99
116
|
require 'golden/action_view/extension'
|
100
117
|
|
101
118
|
class ApplicationController < ActionController::Base
|
102
119
|
helper ::Golden::FormHelper
|
120
|
+
end
|
103
121
|
```
|
104
122
|
|
105
123
|
## Development
|
@@ -110,4 +128,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
110
128
|
|
111
129
|
## Contributing
|
112
130
|
|
113
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/goldenio/golden-objects
|
131
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/goldenio/golden-objects>.
|