rafters 1.0.0 → 1.1.0
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.
- checksums.yaml +4 -4
- data/lib/rafters/component.rb +15 -7
- data/lib/rafters/component_renderer.rb +1 -1
- data/lib/rafters/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff71963c4638eaf225b8ec0cd997188ea1591a17
|
4
|
+
data.tar.gz: 041941674c5c90f078d0d0ffb40a42f3cf1d1527
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 843512e43b3ef5da3a9ad3312e972f69270c5df1d4de8c45169bb9d99d74bb218ec0a106ef3a713cafefbd378a490fc85d072343bea8ce94d861aa718ebf5161
|
7
|
+
data.tar.gz: 166c0648085d5e25a70e34c086dae9f21db86748091f21a371583783ff974bc5f8c96dcb24266d5e5914530cf5902d28b2c66fbe1cc150b36dcd248ae13e857f
|
data/lib/rafters/component.rb
CHANGED
@@ -11,13 +11,24 @@ module Rafters::Component
|
|
11
11
|
def initialize(options = {})
|
12
12
|
raise IdentifierMissing unless options.has_key?(:as)
|
13
13
|
|
14
|
+
@source = if options.has_key?(:source)
|
15
|
+
options.delete(:source).constantize.new(self)
|
16
|
+
end
|
17
|
+
|
14
18
|
@identifier = options.delete(:as)
|
15
19
|
@settings = options.delete(:settings) || {}
|
16
20
|
end
|
17
21
|
|
18
|
-
def name
|
19
|
-
|
20
|
-
|
22
|
+
def name
|
23
|
+
self.class.name.underscore
|
24
|
+
end
|
25
|
+
|
26
|
+
def source
|
27
|
+
if @source.nil?
|
28
|
+
raise SourceMissing
|
29
|
+
else
|
30
|
+
@source
|
31
|
+
end
|
21
32
|
end
|
22
33
|
|
23
34
|
def template_name
|
@@ -28,10 +39,6 @@ module Rafters::Component
|
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
31
|
-
def source
|
32
|
-
@source ||= "#{name(true)}_#{settings.source}_source".camelize.constantize.new(self)
|
33
|
-
end
|
34
|
-
|
35
42
|
def attributes
|
36
43
|
return {} if self.class._attributes.nil?
|
37
44
|
|
@@ -106,6 +113,7 @@ module Rafters::Component
|
|
106
113
|
end
|
107
114
|
end
|
108
115
|
|
116
|
+
class SourceMissing < StandardError; end
|
109
117
|
class IdentifierMissing < StandardError; end
|
110
118
|
class InvalidSetting < StandardError; end
|
111
119
|
end
|
@@ -12,7 +12,7 @@ class Rafters::ComponentRenderer
|
|
12
12
|
|
13
13
|
store(component)
|
14
14
|
|
15
|
-
@controller.view_context.content_tag(:div, class: "component", id: component.identifier) do
|
15
|
+
@controller.view_context.content_tag(:div, class: "component #{component.name.dasherize}", id: component.identifier) do
|
16
16
|
@controller.view_context.render(file: "/#{component.template_name}", locals: component.attributes)
|
17
17
|
end
|
18
18
|
end
|
data/lib/rafters/version.rb
CHANGED