active_type 2.7.1 → 2.8.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 +4 -0
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +40 -16
- 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: 28986180d23a749310c496d900fc83b79ca4bfe305704f2bb93ec6a8c69cf131
|
|
4
|
+
data.tar.gz: 6647ff958ee1be018e654c7689fa333fa3789c1fcb972b6125a4f9e65c0a2aaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18f57bad0539e91f6725ccfd63ceb6faa32a23d96b9033d0bbc240b62f475dd385d03e395f7ba82646078e64add7bc26241848f0c9177568e29699404355c346
|
|
7
|
+
data.tar.gz: 13de6f297c36eb2e2dc75c719f1e8a858a783576f9aaf322e4c46654ae8ee578a8299f73aee651bd64e395ec2dd3a09a6fc02f0b4cbc2977a2ba26c7556d3592
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.8.0 (2026-01-22)
|
|
6
|
+
* Added: Add support `attributes_for_inspect` on ActiveType::Object.
|
|
7
|
+
Tanks to @makmic.
|
|
8
|
+
|
|
5
9
|
## 2.7.1 (2025-11-03)
|
|
6
10
|
* Fixed: Removed some unnecessary files from the packaged gem. Gets rid of symlink warnings during installation.
|
|
7
11
|
|
data/lib/active_type/version.rb
CHANGED
|
@@ -134,6 +134,19 @@ module ActiveType
|
|
|
134
134
|
result
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
+
def self.attribute_for_inspect(value)
|
|
138
|
+
if value.is_a?(String) && value.length > 50
|
|
139
|
+
"#{value[0, 50]}...".inspect
|
|
140
|
+
elsif value.is_a?(Date) || value.is_a?(Time)
|
|
141
|
+
%("#{value.to_formatted_s(:db)}")
|
|
142
|
+
elsif value.is_a?(Array) && value.size > 10
|
|
143
|
+
inspected = value.first(10).inspect
|
|
144
|
+
%(#{inspected[0...-1]}, ...])
|
|
145
|
+
else
|
|
146
|
+
value.inspect
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
137
150
|
extend ActiveSupport::Concern
|
|
138
151
|
|
|
139
152
|
included do
|
|
@@ -141,6 +154,14 @@ module ActiveType
|
|
|
141
154
|
class_attribute :virtual_columns_hash
|
|
142
155
|
self.virtual_columns_hash = {}
|
|
143
156
|
|
|
157
|
+
if respond_to?(:attributes_for_inspect)
|
|
158
|
+
# 7.1 had [:id] as a default, we want a consistent default across all versions
|
|
159
|
+
self.attributes_for_inspect = :all
|
|
160
|
+
else
|
|
161
|
+
# ActiveRecord < 7.2
|
|
162
|
+
class_attribute :attributes_for_inspect, instance_accessor: false, default: :all
|
|
163
|
+
end
|
|
164
|
+
|
|
144
165
|
class << self
|
|
145
166
|
if method_defined?(:attribute)
|
|
146
167
|
alias_method :ar_attribute, :attribute
|
|
@@ -270,25 +291,28 @@ module ActiveType
|
|
|
270
291
|
virtual_attributes[name] = value
|
|
271
292
|
end
|
|
272
293
|
|
|
273
|
-
|
|
294
|
+
def attributes_for_inspect
|
|
295
|
+
self.class.attributes_for_inspect == :all ? attributes.keys : self.class.attributes_for_inspect
|
|
296
|
+
end
|
|
297
|
+
|
|
274
298
|
def inspect
|
|
275
|
-
|
|
276
|
-
"#{name}: #{VirtualAttributes.attribute_for_inspect(value)}"
|
|
277
|
-
end.sort.compact.join(", ")
|
|
278
|
-
"#<#{self.class} #{inspection}>"
|
|
299
|
+
inspect_with_attributes(attributes_for_inspect)
|
|
279
300
|
end
|
|
280
301
|
|
|
281
|
-
def
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
302
|
+
def full_inspect
|
|
303
|
+
inspect_with_attributes(attributes.keys)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# Returns the contents of the record as a nicely formatted string.
|
|
307
|
+
def inspect_with_attributes(attribute_names)
|
|
308
|
+
inspection = attribute_names.collect do |name|
|
|
309
|
+
name = name.to_s
|
|
310
|
+
if attributes.key?(name)
|
|
311
|
+
value = attributes[name]
|
|
312
|
+
"#{name}: #{VirtualAttributes.attribute_for_inspect(value)}"
|
|
313
|
+
end
|
|
314
|
+
end.compact.sort.join(", ")
|
|
315
|
+
"#<#{self.class} #{inspection}>"
|
|
292
316
|
end
|
|
293
317
|
|
|
294
318
|
private
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Kraze
|
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
103
103
|
- !ruby/object:Gem::Version
|
|
104
104
|
version: '0'
|
|
105
105
|
requirements: []
|
|
106
|
-
rubygems_version: 3.6.
|
|
106
|
+
rubygems_version: 3.6.9
|
|
107
107
|
specification_version: 4
|
|
108
108
|
summary: Make any Ruby object quack like ActiveRecord
|
|
109
109
|
test_files: []
|