presenter_object 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 518f904deecb811d75fd12215e6cac057607d178
4
- data.tar.gz: 39c9f1668de7b993ba331b7b023827f1c264855a
3
+ metadata.gz: 132924c09476de5872f7c0df625965de02230dea
4
+ data.tar.gz: e9e43a18c353b8fcb204bf2c9abf748bd790c00d
5
5
  SHA512:
6
- metadata.gz: 3b8f0bef1612d629afc6ff87521218c61aa3360ad2ee5f194d49015f092e38b6e17030d90bcc1875915734ca1c1fe0fc41b0ec5f04b4b8d1eb28538997f22adb
7
- data.tar.gz: a8d9f016f2459174104ae83d20ef9e7ebe1b9bb2d2fc4e52ec04154071dd3363a7decfd14047b69bdbf68f96a91c4f3e22216aebe6781c566432fb14e44c26b8
6
+ metadata.gz: fdf446baa6982dba695dbf5eb8a49c768dd82c8ea02a259e5b695a1f1fb1348c5615223e42b662925fa5c16939f02d442ffe44dcb63fe0eac1579dc1d1215192
7
+ data.tar.gz: aec48caee7e13737f71acd9128e943fb6deb1dac74cfff7c91d5b237780f57521c5b62acc43d9d088c02a85d79081b016a479ea40bcc4086f12bfeb1e2734122
data/README.md CHANGED
@@ -54,6 +54,29 @@ The `@user` presenter object can be used as if it were the model object. Then, j
54
54
  @user.formatted_phone_number # => "(555) 444-3322"
55
55
  ```
56
56
 
57
+ ### Collection Presenter
58
+
59
+ You can also wrap whole collections of objects at once. Create a collection presenter:
60
+
61
+ ```ruby
62
+ class UserCollectionPresenter < PresenterObject::Collection
63
+ def render_table
64
+ each do |object|
65
+ # object is now wrapped in its presenter
66
+ end
67
+ end
68
+ end
69
+ ```
70
+
71
+ Instantiate the collection presenter by passing in an object collection and an optional view_context:
72
+
73
+ ```ruby
74
+ @user_collection = UserCollectionPresenter.new User.all, view_context
75
+ @user_collection.render_table
76
+ ```
77
+
78
+ The `@user_collection` instance is an `Enumerable` and will lazily wrap each object when you iterate over the collection.
79
+
57
80
  ## Development
58
81
 
59
82
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,3 +1,3 @@
1
1
  module PresenterObject
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presenter_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Salazar