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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb87d44d24edcf4229613926623a663f47715af02ec287a84d87618480e0bf61
4
- data.tar.gz: fb652ede3b1a0535be872ebc595c663ceb12b8f205e24a23d114d4c93b2352ea
3
+ metadata.gz: 4ad698392e6eec0c07e6dad7191d9e05de80cbbc748d89e4a4ade15abbc1268b
4
+ data.tar.gz: 03015a5526edc2b9d9b8e7369b29c37693768baa323e0d596ad8b9bf134d0209
5
5
  SHA512:
6
- metadata.gz: 3ec0d2f10fb89604eecc12e34dc5a26ccde337af47eda00ee2b74f9c7dbb43b5ceb1a62209a5d99a34e0dff5516343ca38d268840af240147f3ccf2cd765e9c8
7
- data.tar.gz: 00b23f3b130d76eb08bb63b3c1037838e4de74e9b882d7e6003bed652fa83439663c5efb073dccf8aa05ebcd886dea6201b0db361e8d42efe5e56e2e1739fd2e
6
+ metadata.gz: 9ede8e78272efa09a5a0901b9f17ad797fcb52b88c7286ae374fe1cd737de4655496a829453ffe1879b12be4ae280ef039778875a590ae258b24d4a5fc209910
7
+ data.tar.gz: d542dffaeae9c5f6825727de69621b50124d04b5a67eb0078502480077ded2ce3fd8bf3f7d9f4e1029d7c1411f2605a9deda028426a295b1f88d84042e6bf304
@@ -1,6 +1,10 @@
1
1
  # Change Logs
2
2
 
3
- ### v0.3.0
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
- ### v0.2.0
22
+ ## v0.2.0
19
23
 
20
24
  * Add golden form builder and helper
21
25
  * Golden query context support pluck
22
26
 
23
- ### v0.1.0
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
- $ bundle install
17
+ ``` shell
18
+ bundle install
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install golden-objects
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.all(product_variants: product_variants)
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>.
@@ -56,7 +56,7 @@ module Golden
56
56
  end
57
57
 
58
58
  def result_presenter
59
- @result_presenter ||= result_presenter_class.collect query_result, record_presenter_class
59
+ @result_presenter ||= result_presenter_class.collect query_result, record_presenter_class.name
60
60
  end
61
61
 
62
62
  private
@@ -6,7 +6,7 @@ module Golden
6
6
  def collect(result, presenter_class)
7
7
  new(
8
8
  records: paginated_array(result),
9
- presenter_class: presenter_class
9
+ presenter_class: presenter_class.to_s
10
10
  )
11
11
  end
12
12
 
@@ -1,5 +1,5 @@
1
1
  module Golden
2
2
  module Objects
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden-objects
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tse-Ching Ho