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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46aa108c7fdb1430b81316137e96b4597788c632
4
- data.tar.gz: 40bc5436d5e593f804b3d31bedc38a425ac73a79
3
+ metadata.gz: ff71963c4638eaf225b8ec0cd997188ea1591a17
4
+ data.tar.gz: 041941674c5c90f078d0d0ffb40a42f3cf1d1527
5
5
  SHA512:
6
- metadata.gz: 750fa198c767793cfec5e397b060ae88fbab408b28b3617827e6f25cf50618fdd2d6d733dc34dcbba42c4016397099f0316ce1d7ed15c571234e100413f2e491
7
- data.tar.gz: 65f55f6c3c41678d035a9e1520f848a7f9ede30a34a81390a7686e26ca870944fd37fedc59a61d90d319c6b43f983e8bb610affa04a5d17c128b11dc9ef43700
6
+ metadata.gz: 843512e43b3ef5da3a9ad3312e972f69270c5df1d4de8c45169bb9d99d74bb218ec0a106ef3a713cafefbd378a490fc85d072343bea8ce94d861aa718ebf5161
7
+ data.tar.gz: 166c0648085d5e25a70e34c086dae9f21db86748091f21a371583783ff974bc5f8c96dcb24266d5e5914530cf5902d28b2c66fbe1cc150b36dcd248ae13e857f
@@ -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(without_postfix = false)
19
- _name = self.class.name.underscore
20
- without_postfix ? _name.gsub(/_component/, '') : _name
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
@@ -1,3 +1,3 @@
1
1
  module Rafters
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rafters
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hite