showcase 0.1.4 → 0.1.5

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: 0c3e2b2cefd111fc7d1a066a4d9391e196292ecc
4
- data.tar.gz: 6aeeda275c85e39770048b89ae9b17c747209bd7
3
+ metadata.gz: 97986f4c8b78d2999f33ee25f1f966d72116eddb
4
+ data.tar.gz: d432bc5a7758a657aadea20c3b7212839cc846eb
5
5
  SHA512:
6
- metadata.gz: 0551db2643cffe9fa475f4c3e8a31cc552788a8efd33ad3a2a809f1815dd79d2f31ce291a636dd6fb2b68330ce3c6916566966c1032e4b94d72bead873974a47
7
- data.tar.gz: 9b94f78359199fd20804d1903420e314eed8ece8e8b2a8a18bd8d6158a440d6ed874aac09f38518a4b9c85ab5834994131d4d613f5803fd4e0990f87fda8c41c
6
+ metadata.gz: 389db1473fe7e4fbfefe82e519a0191b9bda00b0fbb5f01d10cdcdb1284c3abb7bb4f19588082a579a161eff9ecabf984a16352bc8f37532c38fd147243fcbdf
7
+ data.tar.gz: bca7eb64152e096c1977b5043bd37340f004aa9b7000c3c01c86bdfe4d891362da99dca621bd2edc48f8b1ef170d5545068008f9f4b15ab58143ca999e00b60e
@@ -31,27 +31,29 @@ module Showcase
31
31
  end
32
32
 
33
33
  def self.presents(*args)
34
- options = args.extract_options!
35
- options.assert_valid_keys(:with)
36
- presenter_klass = options.fetch(:with, nil)
37
-
38
- args.each do |attr|
39
- define_method attr do
40
- present(object.send(attr), presenter_klass, view_context)
41
- end
42
- end
34
+ wrap_methods(args, :present)
43
35
  end
44
36
 
45
37
  def self.presents_collection(*args)
38
+ wrap_methods(args, :present_collection)
39
+ end
40
+
41
+ private
42
+
43
+ def self.wrap_methods(args, method)
46
44
  options = args.extract_options!
47
45
  options.assert_valid_keys(:with)
48
46
  presenter_klass = options.fetch(:with, nil)
49
47
 
50
- args.each do |attr|
51
- define_method attr do
52
- present_collection(object.send(attr), presenter_klass, view_context)
48
+ methods_module = Module.new do
49
+ args.each do |attr|
50
+ define_method attr do
51
+ send(method, object.send(attr), presenter_klass, view_context)
52
+ end
53
53
  end
54
54
  end
55
+
56
+ include(methods_module)
55
57
  end
56
58
  end
57
59
  end
@@ -1,4 +1,4 @@
1
1
  module Showcase
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
4
4
 
data/spec/fixtures.rb CHANGED
@@ -38,11 +38,16 @@ end
38
38
  class ProjectPresenter < Showcase::Presenter
39
39
  presents :owner, with: AdminPresenter
40
40
  presents_collection :collaborators
41
+ presents :owner_child
41
42
 
42
43
  def name
43
44
  "Presented #{object.name}"
44
45
  end
45
46
 
47
+ def owner
48
+ super
49
+ end
50
+
46
51
  def bold_name
47
52
  h.bold(object.name)
48
53
  end
@@ -60,3 +65,9 @@ class Context
60
65
  end
61
66
  end
62
67
 
68
+ class Shop
69
+ def owner
70
+ Person.new("Stefano Verna")
71
+ end
72
+ end
73
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: showcase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna