self_renderer 0.1.0 → 0.1.1

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: 848e357e1ba51e052c701abea3fbeb1a8f289969
4
- data.tar.gz: 7241ccc769b20cfe5f4a5c0d3a5a7c9976723bf7
3
+ metadata.gz: 46e2a834d05504a734dbbdae8e4c4771eeb3f545
4
+ data.tar.gz: 4bf622793d5201ec98bc2f2574a314a911e5d790
5
5
  SHA512:
6
- metadata.gz: fd399730d8ccf230e03ea73fdb0969a8cba1a1f27b2c359fe299611e59a815cf575002b5611fdc20d68a72c8909a98121324eef635ccafaf1a36e414a6defc73
7
- data.tar.gz: 29a9655309e952a3f9599b59f2fcfac7870e5e6cd0a52fa704f0edcd2d5e68582d4b19a1195cf35bfa6b798500f94f52f1f73c68dffc5ea751698ac7b7b3b39b
6
+ metadata.gz: 35e934940725feada8e1332c653c2555ffcf3c5ce2de15d3f28ce3c9e47db8482f73f0aa46f5cbad524bed80724ba852ed5b6a37c8ba91260a5a8d3ea2e114b4
7
+ data.tar.gz: ca047a12c2b5e06d0aca3f58bfc26ebf04439d7722eb2c1ce1071a1eda1198745a46666d7ebcd87dc3cd53ff92e62b23e2d947fc83ec7ee3fe5b90a0c87de203
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- self_renderer (0.1.0)
4
+ self_renderer (0.1.1)
5
5
  activesupport
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -9,18 +9,39 @@ Rails model & object rendering outside the context of web requests.
9
9
 
10
10
  ## Quick Start
11
11
 
12
- ```sh
13
- gem install self_renderer
12
+ ```ruby
13
+ # Gemfile
14
+ gem "self_renderer"
14
15
  ```
15
16
 
16
17
  ```ruby
17
- require "self_renderer"
18
-
18
+ # app/models/user.rb
19
19
  class User < ApplicationRecord
20
20
  include SelfRenderer
21
21
  end
22
22
  ```
23
23
 
24
+ ```erb
25
+ <!-- app/views/users/show.html.erb -->
26
+ <h1>User</h1>
27
+ <%= render "item" %>
28
+ ```
29
+
30
+ ```erb
31
+ <!-- app/views/users/_item.html.erb -->
32
+ <p><%= @user.name %></p>
33
+ ```
34
+
35
+ ```ruby
36
+ # app/views/users/show.json.jbuilder
37
+ json.partial! "item"
38
+ ```
39
+
40
+ ```ruby
41
+ # app/views/users/_item.json.jbuilder
42
+ json.name @user.name
43
+ ```
44
+
24
45
  ```ruby
25
46
  # render html strings
26
47
  User.find(1).render_to_html(template: "users/show.html.erb")
@@ -1,3 +1,3 @@
1
1
  module SelfRenderer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/self_renderer.rb CHANGED
@@ -39,7 +39,7 @@ module SelfRenderer
39
39
  end
40
40
 
41
41
  def render_self(template: nil, partial: nil, assigns: {}, locals: {})
42
- name = self.class.name.parameterize(separator: "_")
42
+ name = self.class.name.parameterize(separator: "_").to_sym
43
43
  assigns[name] = self
44
44
  locals[name] = self
45
45
  return self_renderer.render(template, assigns: assigns, locals: locals).squish if template
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: self_renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins