action_presenter 1.1.4 → 1.1.5
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.
data/CHANGELOG.md
CHANGED
@@ -31,4 +31,9 @@
|
|
31
31
|
|
32
32
|
## Version 1.1.4
|
33
33
|
|
34
|
-
* allow to pass Array as object (klass must be given!)
|
34
|
+
* allow to pass Array as object (klass must be given!)
|
35
|
+
|
36
|
+
## Version 1.1.5
|
37
|
+
|
38
|
+
* revert previous version changes
|
39
|
+
* create #present_collection wchich do what previous version **should** (:sweat:) do
|
@@ -7,18 +7,20 @@ module ActionPresenter
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def present(object, klass = nil)
|
10
|
-
if klass && object.is_a?(Array)
|
11
|
-
object = object.last
|
12
|
-
end
|
13
|
-
|
14
10
|
klass ||= presenter_name object
|
15
11
|
|
12
|
+
object = object.last if object.is_a? Array
|
13
|
+
|
16
14
|
presenter = klass.new(object, view_context)
|
17
15
|
|
18
16
|
return yield presenter if block_given?
|
19
17
|
presenter
|
20
18
|
end
|
21
19
|
|
20
|
+
def present_collection(objects, klass = nil)
|
21
|
+
present([objects], klass)
|
22
|
+
end
|
23
|
+
|
22
24
|
private
|
23
25
|
|
24
26
|
def presenter_name(scope)
|
@@ -49,6 +49,16 @@ describe ActionPresenter::ViewHelper do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
context "#present_collection" do
|
53
|
+
it 'should call present on each element' do
|
54
|
+
collection = ['foo', 'bar']
|
55
|
+
presenter = helper.present_collection(collection, StringPresenter)
|
56
|
+
|
57
|
+
presenter.should be_instance_of StringPresenter
|
58
|
+
presenter.str.should == collection
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
52
62
|
context "#private methods" do
|
53
63
|
context "#presenter_name" do
|
54
64
|
it 'should return constant for object' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -121,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash:
|
124
|
+
hash: 2492449327204744121
|
125
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
126
|
none: false
|
127
127
|
requirements:
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
segments:
|
132
132
|
- 0
|
133
|
-
hash:
|
133
|
+
hash: 2492449327204744121
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project: action_presenter
|
136
136
|
rubygems_version: 1.8.24
|