template_class 1.2.1 → 1.3.0
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/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/lib/template_class/bulk_instantiable.rb +9 -2
- data/lib/template_class/template.rb +0 -5
- data/lib/template_class/version.rb +1 -1
- data/lib/template_class.rb +7 -0
- 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: 668ba7c1bca879891ab4e3d88974a1b426004cf6aebd80d85ea814ba0eb00f3d
|
4
|
+
data.tar.gz: 90b2d1afb78fee8ef58227097e5b5a7b49505cccef447e6e458da94e12ef74e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b288596d3e5612c4fe8e02e0ba6e23201b370839d6f6d6d42bd21a86c2a284f02e42e13208d350eae1faa74f8ef4fb3bbe02f6d8b36d4a4734a479432a6df1d
|
7
|
+
data.tar.gz: 13a7d6ceb090b5c4303061aaaea61fa04520fddb52c980e08e6ba8090ccd8379c7ebd40ddd8a60d458167bda7930adcdf4ab6a58d044e5ca46987afee958be7d
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,18 @@
|
|
8
8
|
### Bug fixes
|
9
9
|
)-->
|
10
10
|
|
11
|
+
## 1.3.0 2025-02-17
|
12
|
+
|
13
|
+
### New features
|
14
|
+
|
15
|
+
- Allow for template classes to create instances with `new`.
|
16
|
+
|
17
|
+
## 1.2.2 2025-01-29
|
18
|
+
|
19
|
+
### Bug fixes
|
20
|
+
|
21
|
+
- Fixed overrides for bulk instantiation not being picked up in Rails >= 7.1.
|
22
|
+
|
11
23
|
## 1.2.1 2025-01-20
|
12
24
|
|
13
25
|
### Bug fixes
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ gem install template_class
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
Include `TemplateClass::Template` in the class or module you want to make into a template. You can
|
29
|
+
Include `TemplateClass::Template` in the class or module you want to make into a template. You can still make instances of a template, but you are expected to *specialize* it to some parameter. By default, any new specialization is an empty class. To define how a specialization is defined from a parameter, call `resolve_template_specialization`. The block you pass will be yielded the parameter that's specializing the template and a class constructor that makes it possible to recursively use the new specialization.
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
class List
|
@@ -10,8 +10,15 @@ module TemplateClass
|
|
10
10
|
into.const_set constant.name.demodulize.to_sym, constant[*args]
|
11
11
|
end
|
12
12
|
.tap { return unless with_overrides } # rubocop:disable Lint/NonLocalExitFromIterator
|
13
|
-
.
|
14
|
-
|
13
|
+
.map do |instance|
|
14
|
+
Object
|
15
|
+
.const_source_location(instance.module_parent_name)
|
16
|
+
.first
|
17
|
+
.delete_suffix('.rb')
|
18
|
+
.then { "#{_1}/#{instance.name.demodulize.underscore}" }
|
19
|
+
end
|
20
|
+
.each do |path|
|
21
|
+
require path
|
15
22
|
rescue LoadError
|
16
23
|
nil
|
17
24
|
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
require 'active_support/core_ext/module/delegation'
|
3
|
-
require 'active_support/core_ext/module/attribute_accessors'
|
4
|
-
|
5
1
|
module TemplateClass
|
6
2
|
module Template
|
7
3
|
extend ActiveSupport::Concern
|
@@ -16,7 +12,6 @@ module TemplateClass
|
|
16
12
|
instance_accessor: false
|
17
13
|
|
18
14
|
singleton_class.delegate :[], :[]=, to: :cache
|
19
|
-
singleton_class.undef_method :new
|
20
15
|
end
|
21
16
|
|
22
17
|
class CacheClassConstructor
|
data/lib/template_class.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
require_relative 'template_class/version'
|
2
|
+
|
3
|
+
require 'active_support/concern'
|
4
|
+
require 'active_support/core_ext/string/inflections'
|
5
|
+
require 'active_support/core_ext/module/delegation'
|
6
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
7
|
+
require 'active_support/core_ext/module/introspection'
|
8
|
+
|
2
9
|
require_relative 'template_class/template'
|
3
10
|
require_relative 'template_class/bulk_instantiable'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: template_class
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moku S.r.l.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|