simpre 0.1.0 → 0.2.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: 8110c3a15c12208aa58335a1b75d9d10e263bddd
4
- data.tar.gz: 6986f19ad9ec7baa0ead2ea7b79af1466c314bc5
3
+ metadata.gz: e97c3313c962c3c47496438f5bb82d07b76baf31
4
+ data.tar.gz: 92f9537c07f664f987b18e5da4b11a91a854a295
5
5
  SHA512:
6
- metadata.gz: 2d1638e859fbf8a740218ff5631a97d6fd38ec6423639a1e0e23f365e46742878844afa849ccebd95218246ee5b91777ee1c29876824c285fd5135486ab0ff94
7
- data.tar.gz: 129d227f8061d87783f7a3c560b5988044f78eac6e29b636c1cfc31fc463454a5454d99835cb2feda178a58a72eb065ed1e7cdf1d4114de8552d0d9a9ccb7a13
6
+ metadata.gz: a03c38dca5a2de2c3a8a22a6a3e50eeeb1420ada16213b99fa0451372ecae71326c701869d1ae2afe5f1df891cb53e38fb146e9f5fcdc521963179d58e1eebe2
7
+ data.tar.gz: 0f446cec167144b2ea9c0e4eba8a1ec8b70ecf71e9ddd49037a7f817a8785616ec87dfec73cec7a9d429da9716ea9a5490a2dec181e3458c33603236493842ef
@@ -1,10 +1,8 @@
1
1
  require 'simpre/helper'
2
2
  require 'simpre/presenter'
3
3
  require 'simpre/version'
4
- require 'simpre/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
5
4
 
6
5
  module Simpre
7
6
  end
8
7
 
9
- ActiveSupport.on_load(:action_controller) { include Simpre::Helper }
10
- ActiveSupport.on_load(:action_view) { include Simpre::Helper }
8
+ require 'simpre/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
@@ -1,16 +1,14 @@
1
1
  module Simpre
2
2
  module Helper
3
-
4
3
  def decorate(item_or_collection)
5
4
  if item_or_collection.respond_to?(:map)
6
- item_or_collection.map{ |item| decorate(item) }
5
+ item_or_collection.map { |item| decorate(item) }
7
6
  else
8
7
  item = item_or_collection
9
8
  decorator = "#{item.class}Presenter".constantize
10
9
  return item if decorator === item
11
- decorator.new(item)
10
+ decorator.new(item, self)
12
11
  end
13
12
  end
14
-
15
13
  end
16
14
  end
@@ -2,5 +2,14 @@ require 'delegate'
2
2
 
3
3
  module Simpre
4
4
  class Presenter < SimpleDelegator
5
+ def initialize(model, view)
6
+ @model = model
7
+ @view = view
8
+ super(@model)
9
+ end
10
+
11
+ def h
12
+ @view
13
+ end
5
14
  end
6
15
  end
@@ -1,5 +1,2 @@
1
- class Simpre::Presenter
2
- def h
3
- ActionController::Base.helpers
4
- end
5
- end
1
+ ActiveSupport.on_load(:action_controller) { include Simpre::Helper }
2
+ ActiveSupport.on_load(:action_view) { include Simpre::Helper }
@@ -1,3 +1,3 @@
1
1
  module Simpre
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.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.1.0
4
+ version: 0.2.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-11 00:00:00.000000000 Z
11
+ date: 2016-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler