material 0.2.20 → 0.2.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a4791e4e4d226abbbecb0820ee50ef195cc11eefb7eed6574e82d00672f60f0
4
- data.tar.gz: 837bdee1cfa4e8ad7c24f97434ffe908d8139951eee655deaec63eb9c1ea9011
3
+ metadata.gz: 9ae59554fed28abb2569c2b32b6bbca5575d60c5af44a7e5830007d8ef49c357
4
+ data.tar.gz: 1bf61511f2eb3064d965c1c3a5be255087159d99dddcecbfb7f0d4f90e9b5a66
5
5
  SHA512:
6
- metadata.gz: 86c5271b33081010631cbc08138353a5ec112ea5f81eb2aad680edcf635008869c9481e7b071406fedfd60b49281f9eefc885c092c9965282337611930510db5
7
- data.tar.gz: be8ba2fa048adf65af6c78e30539da5c162a1ff562df03b4d636967eee0199928f3c38b7e39c017afe1762843e36d969855880cb545204f753682e07ec10285a
6
+ metadata.gz: 025bb61f457490ad7022ec151cde12440c9dfc6b1cb6c1c75796004b3b53b5e7a96a94c538c327c4fb744fa6480aaadd16fc16e98297c3cae5cf4dcbcd8df90f
7
+ data.tar.gz: 8b35d548680cacbcea1e2c7ed8faf23193e064011d02add633cf84c53f8a2d559a39bc0486b102ea1ef00f97c3aa64c2d42099fd90a7fd2add5a821c22d4a688
@@ -5,6 +5,8 @@ module Material
5
5
  module Components
6
6
  extend ActiveSupport::Concern
7
7
 
8
+ CLASSES_TO_DUPLICATE = [ Array, Hash ].freeze
9
+
8
10
  included do
9
11
  class_attribute :_components, instance_writer: false, default: {}
10
12
  end
@@ -62,7 +64,10 @@ module Material
62
64
 
63
65
  def value_for(object)
64
66
  value = object.instance_eval(&@value) if @value.respond_to?(:call)
65
- value.is_a?(Class) ? value : value.dup if value.present?
67
+
68
+ return value.dup if CLASSES_TO_DUPLICATE.any? { |klass| value.is_a?(klass) }
69
+
70
+ value
66
71
  end
67
72
 
68
73
  def configure(**opts, &block)
@@ -5,14 +5,22 @@ module Material
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- register_component(:parent) { default_parent }
9
8
  register_component :filter
10
9
  register_component :filter_default
10
+ register_materialize_component(:parent, :default_parent)
11
11
  register_path_component(:path, :singular_route_key)
12
12
  register_path_component(:index_path, :route_key)
13
13
  end
14
14
 
15
15
  class_methods do
16
+ def register_materialize_component(key, default_value_method = nil)
17
+ register_component(key) { public_send(default_value_method) }
18
+ define_method(key) do
19
+ value = public_send("#{key}_value".to_sym)
20
+ Material::Base.for(value) unless value.nil?
21
+ end
22
+ end
23
+
16
24
  def register_path_component(key, route_key_method)
17
25
  register_component(route_key_method) { try(:model_name)&.public_send(route_key_method) }
18
26
  register_component(key) do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Material
4
- VERSION = "0.2.20"
4
+ VERSION = "0.2.21"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: material
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.20
4
+ version: 0.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-10 00:00:00.000000000 Z
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport