erb_component 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erb_component/erb_component.rb +8 -0
- data/lib/erb_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4becb713a71333702f1e9666fca7490a928b957269cf5129fd78e6670d73edd
|
4
|
+
data.tar.gz: e74b2838a3144406b64f07807d40da29bd52d1a833bcec7e9525c028941fa298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 294198283f9d87a012b24fb7ae8e5d62ee1769180478170547daeed9f07069c76160801076c5b8247d20333aac57c2fb277a1a9fc9858e9c57691a8e1dc98dce
|
7
|
+
data.tar.gz: 18fec35a95417996d5b9e3590186acd3540e69c2ddedee49409d17ee1cdd5c842cce39bec3d487bba7011bf9b178686e988f0bb249e15136ad13c1c5a1c70c19
|
@@ -9,6 +9,7 @@ class ErbComponent
|
|
9
9
|
|
10
10
|
def initialize(req, opts = {})
|
11
11
|
@req = req
|
12
|
+
@template = opts[:template]
|
12
13
|
begin
|
13
14
|
@parent = self.class.superclass == ErbComponent ? nil : self.class.superclass.new(req)
|
14
15
|
if @parent && !(parent.template['{{VIEW}}'] || parent.template['{{view}}'])
|
@@ -41,6 +42,7 @@ class ErbComponent
|
|
41
42
|
@params ||= begin
|
42
43
|
res = @req.params
|
43
44
|
res.merge!(JSON.parse(req.body.read)) if req.post? || req.put? || req.patch?
|
45
|
+
res.merge!(path_hash)
|
44
46
|
res.with_indifferent_access
|
45
47
|
end
|
46
48
|
end
|
@@ -58,6 +60,10 @@ class ErbComponent
|
|
58
60
|
new(opts).render
|
59
61
|
end
|
60
62
|
|
63
|
+
def self.call(req, opts = {})
|
64
|
+
new(req, opts).render
|
65
|
+
end
|
66
|
+
|
61
67
|
def template_file_path
|
62
68
|
file_name = "#{self.class.name.underscore}.erb"
|
63
69
|
if File.exists? "components/#{file_name}"
|
@@ -70,11 +76,13 @@ class ErbComponent
|
|
70
76
|
end
|
71
77
|
|
72
78
|
def template
|
79
|
+
return @template if @template
|
73
80
|
return File.read(template_file_path) if template_file_path
|
74
81
|
fail "not found: #{template_file_path}"
|
75
82
|
end
|
76
83
|
|
77
84
|
def method_missing(m, *args, &block)
|
85
|
+
return super unless m.to_s[0].upcase == m.to_s[0]
|
78
86
|
m = m.to_s
|
79
87
|
str = Kernel.const_defined?("#{self.class}::#{m}") ? "#{self.class}::#{m}" : m
|
80
88
|
clazz = Kernel.const_get(str)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erb_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Karganyan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: React-style front-end components but for ERB?
|
14
14
|
email:
|