atomic_assets 0.0.3 → 0.0.4

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: 0308f62231022a323bb5070c2bd1ea67c9ffc6df
4
- data.tar.gz: a0fe55c21eb72bc320d693de51a1b98a21746e14
3
+ metadata.gz: 1648e917dac6744c8f483cd74a1ff45f2fec5af1
4
+ data.tar.gz: 6e34802f76208c6aca2513c66729e4d99b9d537b
5
5
  SHA512:
6
- metadata.gz: 5d23d2f6cb54109b3e7006db770dc78ed2a3e02c8bdf0b428d5a0197cf4ad0d08ab0b91efa1e087f5337ed2b439eb63df147d751264a8422558fd75b1583ac0f
7
- data.tar.gz: 4fe6d264df4c761c116ec9d61b16cab5fcb462d95863bede7a2a20c3dc3dcb19f9aab31a5f7de4067870b971723279bc25d9a02c21bc7ae4ed85546aa9566f24
6
+ metadata.gz: 9c9ecc027e49d62af642e43f9b387d6b3bdd4e133f381aa80c9a9f5b2544719ce6ba13846c7c6b38e9bec542a2483a7f0abdc61a111b5121034a67dfbd823308
7
+ data.tar.gz: c602eec1ec14c2ea42177e0cd4cdfa41e006ac8e295e19e6781e1d9fc9993b3a0d2a1d18f1abc733bb35b6b255290ef1eda73c62d631e2efc3fcc79e3b5e2055
@@ -7,6 +7,7 @@ module AtomicAssets
7
7
  include Deserialize
8
8
  include Helper
9
9
  include Initialize
10
+ include Options
10
11
  include Render
11
12
  include Serialize
12
13
 
@@ -1,5 +1,5 @@
1
1
  module AtomicAssets
2
- class Railtie < Rails::Railtie
2
+ class Engine < ::Rails::Engine
3
3
  initializer "atomic_assets.setup_autoload_path" do |app|
4
4
  app.config.autoload_paths += %w(app/components)
5
5
  end
@@ -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
@@ -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
- options.merge(options: options)
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/railtie' if defined?(Rails)
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.3
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/railtie.rb
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