kweerie 0.1.2 → 0.1.3

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: f11c69ed8356612d3a1df5dfb98b4751061db706908f7b2efe6ace375f53c73e
4
- data.tar.gz: b33644c5b64bb941bf88bf6207ced00706e84a1c83c2b60fa9c7dddc680dd0fe
3
+ metadata.gz: b17930ae6088ef2d4fb7f4e20c36479bc8bcc97ae2ed3bd2bfd8d7baed4266b0
4
+ data.tar.gz: 7100335df50ba93ee28fb811d530cdf2231db2efaed2f149073144a15e389c41
5
5
  SHA512:
6
- metadata.gz: 9f05d4db4050c840ac87c60b60e44dd27413fc3fee685cd81fd5320d6bb9d37f01ee5a1f29691989f1ec4f3de2a566d1a8fd0057696b54982bdd012170a0ea2b
7
- data.tar.gz: 11560ae4acff559585472f020d29d0367ca431cd3f9398cfb75aa1e27b6a08057e8f6b1d5270b7f6ef043551c9f15d3b95434d586400390c512c75b410dc7661
6
+ metadata.gz: 52f8165082fb447dcc9219c968256f867ead4dba70722920928acedae4e150d9608ee3ffd5dd803131d556031f588b3bba7f8f17171d56cca4487ae427dfb6b4
7
+ data.tar.gz: bdfdf6ecf8cf3495ef4ed157ea3e149d23ff16f5a7ff98a73329dd3f3a1516d80a8a57ddbea1b23dd26df43805a27164a28ba4836550ed9951f7392f07118eb9
data/.rake_tasks~ ADDED
@@ -0,0 +1,20 @@
1
+ build
2
+ build:checksum
3
+ clean
4
+ clobber
5
+ default
6
+ install
7
+ install:local
8
+ release[remote]
9
+ release:guard_clean
10
+ release:rubygem_push
11
+ release:source_control_push[remote]
12
+ rubocop
13
+ rubocop:auto_correct
14
+ rubocop:autocorrect
15
+ rubocop:autocorrect_all
16
+ test
17
+ test:cmd
18
+ test:deps
19
+ test:isolated
20
+ test:slow
@@ -20,7 +20,7 @@ module Kweerie
20
20
  private
21
21
 
22
22
  def generate_result_class(attribute_names)
23
- @generate_result_class ||= Class.new do
23
+ @generate_result_class ||= Class.new(self) do
24
24
  # Include comparison and serialization modules
25
25
  include Comparable
26
26
 
@@ -29,6 +29,20 @@ module Kweerie
29
29
  attr_reader name
30
30
  end
31
31
 
32
+ define_method :initialize do |attrs|
33
+ # Store both raw and casted versions
34
+ @_raw_original_attributes = attrs.dup
35
+ @_original_attributes = attrs.transform_keys(&:to_s).transform_values do |value|
36
+ type_cast_value(value)
37
+ end
38
+
39
+ attrs.each do |name, value|
40
+ casted_value = type_cast_value(value)
41
+ instance_variable_set("@#{name}", casted_value)
42
+ end
43
+ super() if defined?(super)
44
+ end
45
+
32
46
  define_method :type_cast_value do |value|
33
47
  case value
34
48
  when /^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$/ # DateTime check
@@ -64,17 +78,6 @@ module Kweerie
64
78
  end
65
79
  end
66
80
 
67
- define_method :initialize do |attrs|
68
- # Store original attributes with the same type casting
69
- @_original_attributes = attrs.transform_keys(&:to_s).transform_values do |value|
70
- type_cast_value(value)
71
- end
72
-
73
- attrs.each do |name, value|
74
- casted_value = type_cast_value(value)
75
- instance_variable_set("@#{name}", casted_value)
76
- end
77
- end
78
81
  define_method :parse_pg_array do |value|
79
82
  # Remove the curly braces
80
83
  clean_value = value.gsub(/^{|}$/, "")
@@ -115,7 +118,7 @@ module Kweerie
115
118
  attrs = attribute_names.map do |name|
116
119
  "#{name}=#{instance_variable_get("@#{name}").inspect}"
117
120
  end.join(" ")
118
- "#<#{self.class.name || "Record"} #{attrs}>"
121
+ "#<#{self.class.superclass.name} #{attrs}>"
119
122
  end
120
123
 
121
124
  # Hash-like access
@@ -184,6 +187,11 @@ module Kweerie
184
187
  @_original_attributes
185
188
  end
186
189
 
190
+ # Raw attributes access
191
+ define_method :raw_original_attributes do
192
+ @_raw_original_attributes
193
+ end
194
+
187
195
  # ActiveModel-like changes tracking
188
196
  define_method :changed? do
189
197
  to_h != @_original_attributes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kweerie
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kweerie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-06 00:00:00.000000000 Z
11
+ date: 2024-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -59,6 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".rake_tasks~"
62
63
  - ".rubocop.yml"
63
64
  - CHANGELOG.md
64
65
  - LICENSE.txt