glue_gun_dsl 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37182bf278dad7cd5f5db699cb9e190acba48709d53a18bad7102a02acb1987b
4
- data.tar.gz: 4d86c00dc096b5eb90f81c3e6fe7adf0a6ed3e91e4053f0ce88ac898c9e79158
3
+ metadata.gz: e97baa6c4e171ff7016d72e17e6aa8bbaac29f1787334e2adf179286e6e3acab
4
+ data.tar.gz: bf07da1a28c264674715852b26548c82b91c8a752079ce81ab463dddf33dd54c
5
5
  SHA512:
6
- metadata.gz: c5c7416cc73db27881361039fc90d42e9931d8786bfa0364d41e7752b75cc56e0a7fc283a93777a7dfa83b08f71fd3e5fb3714e1223fb7a252a2d9821e95bfae
7
- data.tar.gz: 9bf40cceec7fc4da924b5ae6f44a9ad1994e4d88adc0cf985145896bba847fd2e541e5af9f288c2adf8184b430d51e9237a400fac8724f5413467758aad3f098
6
+ metadata.gz: 773d89754959c7bcdc8aa211e52ba5f62d51803388bbf0938081efea5acbb0eba69fae543a5ef9b41315018fcaa530a2f709e78afe89615f57c85912848fc2e3
7
+ data.tar.gz: c85ffa384466da228d4442b303db20bd07ae83262981b24b10675d67eaca168f7bdf6a14f88ee617c780402086b10677fc0302b8d08096851bfbcebb5294a2bf
@@ -0,0 +1,28 @@
1
+ module GlueGun
2
+ module Types
3
+ class ArrayType < ActiveModel::Type::Value
4
+ def cast(value)
5
+ case value
6
+ when String
7
+ parse_string(value)
8
+ when Array
9
+ value
10
+ else
11
+ []
12
+ end
13
+ end
14
+
15
+ def serialize(value)
16
+ value.to_json
17
+ end
18
+
19
+ private
20
+
21
+ def parse_string(value)
22
+ JSON.parse(value)
23
+ rescue JSON::ParserError
24
+ []
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ module GlueGun
2
+ module Types
3
+ require_relative "glue_gun/types/hash_type"
4
+ ActiveModel::Type.register(:hash, GlueGun::Types::HashType)
5
+
6
+ require_relative "glue_gun/types/array_type"
7
+ ActiveModel::Type.register(:array, GlueGun::Types::ArrayType)
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GlueGun
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/glue_gun.rb CHANGED
@@ -2,8 +2,6 @@ require "active_model"
2
2
  require "active_support/concern"
3
3
 
4
4
  module GlueGun
5
- require_relative "glue_gun/types/hash_type"
6
- ActiveModel::Type.register(:hash, GlueGun::Types::HashType)
7
-
5
+ require_relative "glue_gun/types"
8
6
  require_relative "glue_gun/dsl"
9
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glue_gun_dsl
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
  - Brett Shollenberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-03 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -129,6 +129,8 @@ extra_rdoc_files: []
129
129
  files:
130
130
  - lib/glue_gun.rb
131
131
  - lib/glue_gun/dsl.rb
132
+ - lib/glue_gun/types.rb
133
+ - lib/glue_gun/types/array_type.rb
132
134
  - lib/glue_gun/types/hash_type.rb
133
135
  - lib/glue_gun/version.rb
134
136
  homepage: https://github.com/brettshollenberger/glue_gun