presenter_object 0.2.3 → 0.2.4

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: ba318d03b041c36513036dacf2bf5e16f4d91fa6
4
- data.tar.gz: c2e442471e91117a7333bd316f04ec30132cc656
3
+ metadata.gz: 4db23d97099762959c245d3fd2ca7dc4960922a0
4
+ data.tar.gz: f69f054e06a994404e89f11a9f49b7e9c0f3df35
5
5
  SHA512:
6
- metadata.gz: 1ad28122e2215dc097d60f42886a3fcf046353ec7abf49561d9f379407ed04766c033c2334b2c4247f9dc8406e9a03b7e58ace262080917e36df1a17381d3c12
7
- data.tar.gz: 69222e141173db4d753d52bd851c23138630f0bd8429c6e68fb44200a84acd597cb9e5710f6a263003bfa2275049e34c13dde2f04043278362c225cb5013ec79
6
+ metadata.gz: 4db85001d3aaec96bb6b98d9a19d8d12c13b4fd1e8e383984f08f42267a7ab44c69d64d5c6347dfcbc7ec11f8702cdf99548fb7ca195a3cdb6a37412447f32f0
7
+ data.tar.gz: e70d1a61d2d9c0edc6f7f67de77f6c121e1ac4e705158cb76a8a9714d72d020cbf7a635f66735f77eaa6e7bd55dcb0739eb053723439338d51d2a8b8335fa7e8
@@ -7,5 +7,11 @@ require "presenter_object/presentable"
7
7
  require "presenter_object/collection"
8
8
 
9
9
  module PresenterObject
10
+ SUFFIX = "Presenter"
10
11
 
12
+ def self.load_presenter!(name)
13
+ Object.const_get "#{name}#{SUFFIX}"
14
+ rescue NameError
15
+ nil
16
+ end
11
17
  end
@@ -9,15 +9,18 @@
9
9
  # document = Document.find(params[:id]).presenterize
10
10
  #
11
11
  module PresenterObject::Presentable
12
- extend ActiveSupport::Concern
13
-
14
12
  PresenterNotRegistered = Class.new KeyError
13
+ extend ActiveSupport::Concern
15
14
 
16
15
  module ClassMethods
17
16
  def presenter_class
18
- PresenterObject::Base.presenters.fetch name.demodulize
17
+ PresenterObject::Base.presenters.fetch name
19
18
  rescue KeyError
20
- raise PresenterNotRegistered, "No presenter registered for #{name}. Is it defined and loaded?"
19
+ if (presenter = PresenterObject.load_presenter!(name))
20
+ presenter
21
+ else
22
+ raise PresenterNotRegistered, "No presenter registered for #{name}. Is it defined and loaded?"
23
+ end
21
24
  end
22
25
  end
23
26
 
@@ -1,3 +1,3 @@
1
1
  module PresenterObject
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
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.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Salazar