rubyanh-presenter 0.2.1 → 0.2.2

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: 158b8fefb69635f2149d0efcbcb68ecf2f95801d
4
- data.tar.gz: b52c45ce10639446dab47a94581a8c911bcf7c83
3
+ metadata.gz: 342c2f9af041e3ff6663544d0796f7d8b1933d46
4
+ data.tar.gz: a28b9342fcea481ef8bd53bfeb7f390d59fe9952
5
5
  SHA512:
6
- metadata.gz: 18a02d8b36413dd3b86c975a6acec8f1fc4dbf2c55ba25ae977eb22d211ad4c2a2296fdb28c8a0ed510818be83b6e059a211ebf3d5499a77b7e2a28510088b09
7
- data.tar.gz: 7d9ee46814fb31c05094d426ae24838eb616ee80e027f80a1dee31b74bb2ef482fc3be033c813588f0e5c64179fd13bc19ded84fdd0c0ec9ab5393e3a23e0fa2
6
+ metadata.gz: 058e6341204ce0c911cc28fb00c50268169768b89dcee48f1d41058c8765e80d5ebfdef5567c0d5c5fbd7e8b28d69a5ece45e13c4603b5accd36760bf690b5c7
7
+ data.tar.gz: b1a2aad42a5a8d15bca6bfe1cf3a129d2615d39f5fc6912be27094a41c9e8fe52de286e0c23537dd926fd969a0aa1ed654d92e503adc0c771dfb796391ec90bb
data/lib/presenter.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "rails"
2
+
3
+ module Presenter
4
+ autoload :Presentable, 'presenter/presentable'
5
+ autoload :BasePresenter, 'presenter/base'
6
+ autoload :NullPresenter, 'presenter/null'
7
+ end
@@ -0,0 +1,7 @@
1
+ module Presenter
2
+ class BasePresenter
3
+ def initialize(model)
4
+ @model = model
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Presenter
2
+ class NullPresenter < BasePresenter
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ module Presenter
2
+ module Presentable
3
+ def presenter
4
+ presenter_class = "#{self.class}Presenter".safe_constantize
5
+
6
+ if presenter_class.nil?
7
+ return NullPresenter.new(self)
8
+ end
9
+
10
+ presenter_class.new(self)
11
+ end
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyanh-presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giang Thai Cuong
@@ -62,6 +62,10 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - README.md
65
+ - lib/presenter.rb
66
+ - lib/presenter/base.rb
67
+ - lib/presenter/null.rb
68
+ - lib/presenter/presentable.rb
65
69
  homepage: https://github.com/rubyanh/presenter
66
70
  licenses:
67
71
  - MIT