camel_snake_struct 0.3.2 → 0.3.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: 810f5a99f464439e0e6ebeebad3df0dbfb41bcd868a8d0418cfe60b6df7c9b8e
4
- data.tar.gz: a8e071224633a912dc8ca9f32ee2aaeb03b2e5f0c1bd63b7a1f910d38d53e0d5
3
+ metadata.gz: 97260b87ce81c6f4978d10d4270bd174bfd11bb6ef6bbce8c9138cb9cf383296
4
+ data.tar.gz: 0b6ca2254ef5e5d5c7eb0820570110799ffc473a3ae0a55029ba59c27f2050d4
5
5
  SHA512:
6
- metadata.gz: e272d3ebeb81fa42f0a61c6f31e398d41f16a1fb6a946c2091cd469dae8f2f171cc5ca02b2185c2fc24504fe723218eec4f83f942c863ff8d1f48e00878c6aaa
7
- data.tar.gz: 49d5154129c2a0497e549b50b8caade8ab6533d329c8a7d2c5853d59f95d084511c7a58b3b02573c7582a5ffad7638aa9981c3edfc7ef00eb8f503981a4e1409
6
+ metadata.gz: '044484cd1956e71dcc40306c860631729075df2eb1eb4b7726b0b382fc0e0473ff2028ac940174ed60b5fbc5003096775605aa25428a17d0631255eddc23f4fc'
7
+ data.tar.gz: 5e1d558fba3441f9cd6cfc1e273834003d3bd58d8e8c37313c238e4196156e91556d0656ad9681d0f26560fb6a064ec3f0d00e4d98902f9443f98d6d8893ae5d
data/README.md CHANGED
@@ -98,6 +98,8 @@ module Tapioca
98
98
  sig { override.void }
99
99
  def decorate
100
100
  root.create_path(constant) do |klass|
101
+ klass.create_method('to_h', parameters: [], return_type: "T::Hash[String, T.untyped]")
102
+
101
103
  constant.types_meta_data.each do |name, meta_data|
102
104
  classes = meta_data.classes.to_a.map{|a| [TrueClass,FalseClass].include?(a) ? "T::Boolean" : a.to_s }.uniq
103
105
  return_type = if classes.size == 1
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "camel_snake_struct"
3
- spec.version = "0.3.2"
3
+ spec.version = "0.3.3"
4
4
  spec.authors = ["Grant Petersen-Speelman"]
5
5
  spec.email = ["grant@nexl.io"]
6
6
 
@@ -29,15 +29,22 @@ class CamelSnakeStruct
29
29
  end
30
30
 
31
31
  def self.store_meta_data(example_class, m_name, result)
32
- types_meta_data = (example_class.types_meta_data[m_name] ||= Type__Meta__Data.new(Set.new, false))
33
32
  if result.is_a?(Array)
34
- types_meta_data.array = true
35
- result.map(&:class).each { |c| types_meta_data.class_types << c }
33
+ add_array_meta_data(example_class, m_name, result)
36
34
  else
35
+ types_meta_data = (example_class.types_meta_data[m_name] ||= Type__Meta__Data.new(Set.new, false))
37
36
  types_meta_data.class_types << result.class
38
37
  end
39
38
  end
40
39
 
40
+ def self.add_array_meta_data(example_class, m_name, result)
41
+ return if result.length == 0
42
+
43
+ types_meta_data = (example_class.types_meta_data[m_name] ||= Type__Meta__Data.new(Set.new, false))
44
+ types_meta_data.array = true
45
+ result.map(&:class).each { |c| types_meta_data.class_types << c }
46
+ end
47
+
41
48
  def self.types_meta_data
42
49
  @types_meta_data ||= {}
43
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camel_snake_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Petersen-Speelman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-19 00:00:00.000000000 Z
11
+ date: 2024-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -58,7 +58,7 @@ metadata:
58
58
  source_code_uri: https://github.com/NEXL-LTS/camel_snake_struct-ruby
59
59
  changelog_uri: https://github.com/NEXL-LTS/camel_snake_struct/CHANGELOG.md
60
60
  rubygems_mfa_required: 'true'
61
- post_install_message:
61
+ post_install_message:
62
62
  rdoc_options: []
63
63
  require_paths:
64
64
  - lib
@@ -73,8 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.1.6
77
- signing_key:
76
+ rubygems_version: 3.4.19
77
+ signing_key:
78
78
  specification_version: 4
79
79
  summary: Easily access camelCased hashes in a ruby friendly way
80
80
  test_files: []