material 0.2.11 → 0.2.12
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 +4 -4
- data/lib/material/base.rb +8 -0
- data/lib/material/concerns/collection.rb +32 -0
- data/lib/material/list.rb +1 -15
- data/lib/material/version.rb +1 -1
- data/lib/material.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5ded57612bad30122179909d02f23dc9cd6d95d8753b38a34e66e7e63733b7
|
4
|
+
data.tar.gz: f0cf9ea4391602a51124e9e31144b09a5411d34d63f482809e16043b7077dbb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a370486799c5418ce9348f9acc4b82bbf0b6acf2dd58a1bcf254547943aec19940d5363fcb9cd56e858f6d036864f69fd021f901ae42cf4d9a161d7ff9e8fe8
|
7
|
+
data.tar.gz: 68178b2c5cccb6b1edf9d59eabd1444c4a25b063524da60f094efb7cc282952a3535cc989843237731a18ccc5480c57397dae59f94bdf20125386d88983ef5f4
|
data/lib/material/base.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Material
|
4
|
+
module Collection
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
class_methods do
|
8
|
+
def item_class
|
9
|
+
return item_enforcement if item_enforcement.is_a?(Class)
|
10
|
+
|
11
|
+
item_class = superclass.__send__(:item_enforcement) if superclass.respond_to?(:item_enforcement, true)
|
12
|
+
return item_class if item_class.present?
|
13
|
+
|
14
|
+
# Prevents against the case of `Material::List` becoming `Material` and returning a module
|
15
|
+
item_class = name.chomp("List").safe_constantize
|
16
|
+
item_class if item_class.is_a?(Class)
|
17
|
+
end
|
18
|
+
|
19
|
+
def ensure_item_validity_with
|
20
|
+
super || item_class
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_ary
|
25
|
+
ary = super
|
26
|
+
return ary if ary.empty?
|
27
|
+
|
28
|
+
material_class = self.class.material_class_for(ary.first, "Material")
|
29
|
+
material_class.nil? ? ary : ary.map(&material_class.method(:new))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/material/list.rb
CHANGED
@@ -13,27 +13,13 @@ module Material
|
|
13
13
|
include Material::For
|
14
14
|
include Material::Pagination
|
15
15
|
include Material::Mount
|
16
|
+
include Material::Collection
|
16
17
|
|
17
18
|
class << self
|
18
19
|
def for(object)
|
19
20
|
material_class = material_class_for(object, "List")
|
20
21
|
material_class.new if material_class.present?
|
21
22
|
end
|
22
|
-
|
23
|
-
def item_class
|
24
|
-
return item_enforcement if item_enforcement.is_a?(Class)
|
25
|
-
|
26
|
-
item_class = superclass.__send__(:item_enforcement) if superclass.respond_to?(:item_enforcement, true)
|
27
|
-
return item_class if item_class.present?
|
28
|
-
|
29
|
-
# Prevents against the case of `Material::List` becoming `Material` and returning a module
|
30
|
-
item_class = name.chomp("List").safe_constantize
|
31
|
-
item_class if item_class.is_a?(Class)
|
32
|
-
end
|
33
|
-
|
34
|
-
def ensure_item_validity_with
|
35
|
-
super || item_class
|
36
|
-
end
|
37
23
|
end
|
38
24
|
|
39
25
|
def default_title
|
data/lib/material/version.rb
CHANGED
data/lib/material.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative "material/concerns/site"
|
|
12
12
|
require_relative "material/concerns/for"
|
13
13
|
require_relative "material/concerns/pagination"
|
14
14
|
require_relative "material/concerns/mount"
|
15
|
+
require_relative "material/concerns/collection"
|
15
16
|
|
16
17
|
require "material/version"
|
17
18
|
|
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.12
|
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-09-
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- README.md
|
209
209
|
- lib/material.rb
|
210
210
|
- lib/material/base.rb
|
211
|
+
- lib/material/concerns/collection.rb
|
211
212
|
- lib/material/concerns/components.rb
|
212
213
|
- lib/material/concerns/core.rb
|
213
214
|
- lib/material/concerns/for.rb
|