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 +4 -4
- data/lib/material/concerns/components.rb +6 -1
- data/lib/material/concerns/site.rb +9 -1
- data/lib/material/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae59554fed28abb2569c2b32b6bbca5575d60c5af44a7e5830007d8ef49c357
|
4
|
+
data.tar.gz: 1bf61511f2eb3064d965c1c3a5be255087159d99dddcecbfb7f0d4f90e9b5a66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/material/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|