atomic_assets 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/atomic_assets/component.rb +1 -0
- data/lib/atomic_assets/{railtie.rb → engine.rb} +1 -1
- data/lib/atomic_assets/options.rb +25 -0
- data/lib/atomic_assets/render.rb +14 -3
- data/lib/atomic_assets.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1648e917dac6744c8f483cd74a1ff45f2fec5af1
|
4
|
+
data.tar.gz: 6e34802f76208c6aca2513c66729e4d99b9d537b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9ecc027e49d62af642e43f9b387d6b3bdd4e133f381aa80c9a9f5b2544719ce6ba13846c7c6b38e9bec542a2483a7f0abdc61a111b5121034a67dfbd823308
|
7
|
+
data.tar.gz: c602eec1ec14c2ea42177e0cd4cdfa41e006ac8e295e19e6781e1d9fc9993b3a0d2a1d18f1abc733bb35b6b255290ef1eda73c62d631e2efc3fcc79e3b5e2055
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AtomicAssets
|
2
|
+
module Options
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
base.class_attribute :option_settings
|
6
|
+
base.option_settings = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def option(name, settings = {})
|
11
|
+
self.option_settings = self.option_settings.merge(
|
12
|
+
name.to_sym => settings
|
13
|
+
)
|
14
|
+
|
15
|
+
define_method(name) do
|
16
|
+
self.options[name]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def option_keys
|
21
|
+
option_settings.keys
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/atomic_assets/render.rb
CHANGED
@@ -15,6 +15,10 @@ module AtomicAssets
|
|
15
15
|
render_partial
|
16
16
|
end
|
17
17
|
|
18
|
+
def render_options
|
19
|
+
default_options.merge(options)
|
20
|
+
end
|
21
|
+
|
18
22
|
def template_path
|
19
23
|
File.join(COMPONENT_PATH, component_name)
|
20
24
|
end
|
@@ -29,18 +33,25 @@ module AtomicAssets
|
|
29
33
|
self.class.name.underscore.gsub(/_component$/, '')
|
30
34
|
end
|
31
35
|
|
36
|
+
def default_options
|
37
|
+
self.class.option_keys.map do |key|
|
38
|
+
[key, nil]
|
39
|
+
end.to_h
|
40
|
+
end
|
41
|
+
|
32
42
|
def local_options
|
33
|
-
|
43
|
+
opts = render_options
|
44
|
+
opts.merge(options: opts)
|
34
45
|
end
|
35
46
|
|
36
47
|
def render_partial
|
37
|
-
output = h.render(partial: template_path, locals: local_options)
|
48
|
+
output = h.render(partial: template_path, locals: local_options, formats: [:html])
|
38
49
|
ActiveSupport::Deprecation.warn(PARTIALS_DEPRECATED)
|
39
50
|
output
|
40
51
|
end
|
41
52
|
|
42
53
|
def render_template
|
43
|
-
h.render(template: template_path, locals: local_options)
|
54
|
+
h.render(template: template_path, locals: local_options, formats: [:html])
|
44
55
|
end
|
45
56
|
end
|
46
57
|
end
|
data/lib/atomic_assets.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'atomic_assets/deserialize'
|
2
2
|
require 'atomic_assets/helper'
|
3
3
|
require 'atomic_assets/initialize'
|
4
|
+
require 'atomic_assets/options'
|
4
5
|
require 'atomic_assets/render'
|
5
6
|
require 'atomic_assets/serialize'
|
6
|
-
require 'atomic_assets/
|
7
|
+
require 'atomic_assets/engine' if defined?(Rails)
|
7
8
|
|
8
9
|
require 'atomic_assets/component'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Don Humphreys
|
@@ -89,9 +89,10 @@ files:
|
|
89
89
|
- lib/atomic_assets.rb
|
90
90
|
- lib/atomic_assets/component.rb
|
91
91
|
- lib/atomic_assets/deserialize.rb
|
92
|
+
- lib/atomic_assets/engine.rb
|
92
93
|
- lib/atomic_assets/helper.rb
|
93
94
|
- lib/atomic_assets/initialize.rb
|
94
|
-
- lib/atomic_assets/
|
95
|
+
- lib/atomic_assets/options.rb
|
95
96
|
- lib/atomic_assets/render.rb
|
96
97
|
- lib/atomic_assets/serialize.rb
|
97
98
|
homepage: http://github.com/dhumphreys/atomic_assets
|