lucid_shopify 0.27.1 → 0.28.0

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: 80f4d6faf6711e98fb9f7f72297cc039278c672902aabb505b761a8536bb277f
4
- data.tar.gz: 5e860d2639f4bd61ae45c7c50d950a9ce2d39104af3f01de2fce66368e9d1cb3
3
+ metadata.gz: 10054d2fb445e9c404820b50cb5f98b838d0431bf977ff4aaf8cd2e45fd52315
4
+ data.tar.gz: 13a4ca4660f85f79d6614c9fd2fdc406381a5a97391ad55e8d6eb3bdc9e868e7
5
5
  SHA512:
6
- metadata.gz: 59b5f0e99293261319dd76efde0067c21d389c9dde510e20d35e746deb8a2f05e867c0274f927ffd761db0e42703f9c616b49b230a75bd91f36106624380e320
7
- data.tar.gz: ebc3c2d8e9e1782725c6b4a090736644c55079822572da40d6d0d641c7b15891220b0a0b46cdfd0585b13f97c1b02ca3ede10c5a48b04ee6a9d9f4024ac9b783
6
+ metadata.gz: 1a6c6ded622ad8210f1d8652c5ffaa4b39fb49bd11109b8051452c815b1e2bd5480e5bc234ba43903f260d377842b7cd58310ccec3d7c85918605b1e67617f3e
7
+ data.tar.gz: b79e3439b6261556d1c6346523230a5cd9748a7389e53322b56dc8dc818284a4ebd0cc64f67dc5376b3cfd51c0695f88891800353664577310e8b4e57a438cd4
@@ -40,16 +40,16 @@ module LucidShopify
40
40
  param :headers
41
41
  # @return [String]
42
42
  param :data
43
- # @return [Hash] the parsed response body
44
- param :data_hash, default: -> { parse_data }
45
43
 
44
+ #
45
+ # The parsed response body.
46
46
  #
47
47
  # @return [Hash]
48
48
  #
49
- private def parse_data
49
+ private def data_hash
50
50
  return {} unless json?
51
51
 
52
- JSON.parse(data)
52
+ @data_hash ||= JSON.parse(data)
53
53
  end
54
54
 
55
55
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucidShopify
4
- VERSION = '0.27.1'
4
+ VERSION = '0.28.0'
5
5
  end
@@ -14,16 +14,46 @@ module LucidShopify
14
14
  param :topic
15
15
  # @return [String]
16
16
  param :data
17
- # @return [Hash] the parsed request body
18
- param :data_hash, default: -> { parse_data }
19
17
 
20
18
  #
21
19
  # @return [Hash]
22
20
  #
23
- private def parse_data
24
- JSON.parse(data)
21
+ def data_hash
22
+ @data_hash ||= JSON.parse(data)
25
23
  rescue JSON::ParserError
26
24
  {}
27
25
  end
26
+
27
+ #
28
+ # @see Hash#each
29
+ #
30
+ def each(&block)
31
+ data_hash.each(&block)
32
+ end
33
+
34
+ #
35
+ # @param key [String]
36
+ #
37
+ # @return [Object]
38
+ #
39
+ def [](key)
40
+ data_hash[key]
41
+ end
42
+
43
+ alias_method :to_h, :data_hash
44
+
45
+ #
46
+ # @return [Hash]
47
+ #
48
+ def as_json(*)
49
+ to_h
50
+ end
51
+
52
+ #
53
+ # @return [String]
54
+ #
55
+ def to_json(*args)
56
+ as_json.to_json(*args)
57
+ end
28
58
  end
29
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid_shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.1
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelsey Judson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2019-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv