base_presenter 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,28 +20,43 @@ Or install it yourself as:
20
20
 
21
21
  In director root_rails/app/presenters create file example_presenter.rb with content
22
22
 
23
- class ExamplePresenter < BasePresenter
24
- presents :example
25
- delegate :name, :example
23
+ ```ruby
24
+ class ExamplePresenter < BasePresenter
25
+ presents :example
26
+ delegate :name, :example
26
27
 
27
- def name
28
- "Name"
29
- end
28
+ def name
29
+ "Name"
30
+ end
30
31
 
31
- def self.class_name
32
- "Example"
33
- end
34
- end
32
+ def self.class_name
33
+ "Example"
34
+ end
35
+ end
36
+ ```
35
37
 
36
38
  and in file show.html.erb with:
37
- * object @example
39
+ * object `@example`
38
40
 
39
- <% present @example do |presenter| %>
40
- Name: <%= presenter.name %>
41
- <% end %>
41
+ ```erb
42
+ <% present @example do |presenter| %>
43
+ Name: <%= presenter.name %>
44
+ <% end %>
45
+ ```
42
46
 
43
- * class Example
47
+ * class `Example`
48
+
49
+ ```erb
50
+ <% present Example do |presenter| %>
51
+ Class name: <%= presenter.class_name %>
52
+ <% end %>
53
+ ```
54
+ ## Methods
55
+
56
+ Methods of BasePresenter
57
+
58
+ Method returns span with 'None given' when value is blank
59
+ ```erb
60
+ #handle_none(value)
61
+ ```
44
62
 
45
- <% present Example do |presenter| %>
46
- Class name: <%= presenter.class_name %>
47
- <% end %>
@@ -1,3 +1,3 @@
1
1
  class BasePresenter
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "base_presenter/version"
2
2
  require "application_helper"
3
+
3
4
  class BasePresenter
4
5
 
5
6
  def initialize(object, template)
@@ -8,14 +9,15 @@ class BasePresenter
8
9
  end
9
10
 
10
11
  def method_missing(*args, &block)
11
- h.send(*args, &block)
12
+ @template.send(*args, &block)
12
13
  end
13
14
 
15
+ # Return span with 'None given' when value is blank
14
16
  def handle_none(value)
15
17
  if value.present?
16
18
  yield
17
19
  else
18
- h.content_tag :span, "None given", class: "none"
20
+ content_tag :span, "None given", class: "none"
19
21
  end
20
22
  end
21
23
 
@@ -27,15 +29,11 @@ class BasePresenter
27
29
  @object
28
30
  end
29
31
  end
30
- end
31
-
32
- private
33
32
 
34
- def self.h
35
- @@template
33
+ def method_missing(*args, &block)
34
+ @@template.send(*args, &block)
36
35
  end
37
36
 
38
- def h
39
- @template
40
- end
37
+ end
38
+
41
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: