base_presenter 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -18,12 +18,19 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ In director root_rails/app/presenters create file example_presenter.rb with content
22
22
 
23
- ## Contributing
23
+ class ExamplePresenter < BasePresenter
24
+ presents :example
25
+ delegate :name, :example
24
26
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
27
+ def name
28
+ "Name"
29
+ end
30
+ end
31
+
32
+ and in file show.html.erb
33
+
34
+ <% present @example do |presenter| %>
35
+ Name: <%= presenter.name %>
36
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  class BasePresenter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,20 @@
1
1
  require "base_presenter/version"
2
2
 
3
3
  class BasePresenter
4
- # Your code goes here...
4
+
5
+ def initialize(object, template)
6
+ @object = object
7
+ @template = template
8
+ end
9
+
10
+ def self.presents(name)
11
+ define_method(name) do
12
+ @object
13
+ end
14
+ end
15
+
16
+ def method_missing(*args, &block)
17
+ @template.send(*args, &block)
18
+ end
19
+
5
20
  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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: