simpre 0.2.0 → 0.3.0

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: e97c3313c962c3c47496438f5bb82d07b76baf31
4
- data.tar.gz: 92f9537c07f664f987b18e5da4b11a91a854a295
3
+ metadata.gz: 6dc40f25d30355671a427638f7a35949dcd93b2a
4
+ data.tar.gz: 4413d0944e2ca4575c75b886032f1d3eb8a8bf23
5
5
  SHA512:
6
- metadata.gz: a03c38dca5a2de2c3a8a22a6a3e50eeeb1420ada16213b99fa0451372ecae71326c701869d1ae2afe5f1df891cb53e38fb146e9f5fcdc521963179d58e1eebe2
7
- data.tar.gz: 0f446cec167144b2ea9c0e4eba8a1ec8b70ecf71e9ddd49037a7f817a8785616ec87dfec73cec7a9d429da9716ea9a5490a2dec181e3458c33603236493842ef
6
+ metadata.gz: 868ad1b7a1f31dffccc93f0f1c635e51731e08de3a33f578ae725ea313faa351f9ea5f4bfc3699f5b8bc25d523ef2916eee36aadbf047036d8477ef6b19091f4
7
+ data.tar.gz: 3b875cda3597592c0b1c9bcdbc446e5aca515e1e70dc5a1eb9677f7a20baadeaedce8453fc7a42eefe788bccf955d0dec42867b3cf26c8009823b20a3b0a82cf
data/lib/simpre/helper.rb CHANGED
@@ -5,10 +5,16 @@ module Simpre
5
5
  item_or_collection.map { |item| decorate(item) }
6
6
  else
7
7
  item = item_or_collection
8
- decorator = "#{item.class}Presenter".constantize
9
- return item if decorator === item
10
- decorator.new(item, self)
8
+ presenter = "#{item.class}Presenter".constantize
9
+ return item if item.instance_of?(presenter)
10
+ presenter.new(item, current_view_context)
11
11
  end
12
12
  end
13
+
14
+ private
15
+
16
+ def current_view_context
17
+ is_a?(ApplicationController) ? view_context : self
18
+ end
13
19
  end
14
20
  end
@@ -11,5 +11,8 @@ module Simpre
11
11
  def h
12
12
  @view
13
13
  end
14
+
15
+ # Create a nicer method to get the decorated object
16
+ alias_method :object, :__getobj__
14
17
  end
15
18
  end
@@ -1,3 +1,3 @@
1
1
  module Simpre
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Dyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-12 00:00:00.000000000 Z
11
+ date: 2016-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler