e_plat 0.4.1 → 0.4.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: 63cb25eee6d28946048f347ddc3838b70b1166b7c2967cdd366415ed01934293
4
- data.tar.gz: 0dd57db7198622888e6ecc5d06e122c396a3b73c60c62b9d1d2da269783a571f
3
+ metadata.gz: ee797b0b23712947fd4ed9e566a4a26548b887fc7958254343eab9b97073e708
4
+ data.tar.gz: d26e103052bf4fbf770890e5b05d0f49dcf4c6cd9ae4f473e3737640837fa148
5
5
  SHA512:
6
- metadata.gz: 04c061335ab6957ff48b665eb6260447e43989f900e0b4de9e9984ee6bcb3157d574aae8806d26cfa211414a871a50fc062c67d33ce1ea1df2a123c0d71e00cc
7
- data.tar.gz: 0abe12aeb34a95283adfcc91a78260a9f69e7137011fec179e0912c171e29f31fb8caadbb563e15d2bb9f151ac2351574f3884800b7fd4610681e4e85bcf27a6
6
+ metadata.gz: 213183bc25f835b78a18245f01cab417cd37625baf056e08a89500f492d3b019ee8691da997e33e60c8c4b7ea894eaf5120d7806b943fe001be3f888b58e74ce
7
+ data.tar.gz: 464bb8e454266a48d6e157bd5e51f689216e59afc3bde7506a3ec3ae4ea1030bf4b0b3e3288b205ba88976885be76a1f6df2829dd93f5d7cae9d87ea977b8742
data/README.md CHANGED
@@ -833,6 +833,11 @@ product.title = "oi"
833
833
  product.changed_attributes # {"name"=>"oi", "title"=>"oi"}
834
834
  #title is the e_plat key which won't be included in requests to the server. The native key 'name' has automatically been updated and will be sent in requests.
835
835
 
836
+ product.as_json # hash of any updated attributes
837
+ product.as_full_json # hash of all attributes, regardless of if they've been updated or not
838
+ product.to_json # JSON string of any updated_attributes
839
+ product.to_full_json # JSON string of all attributes. regardless of if they've been updated or not
840
+
836
841
  ```
837
842
 
838
843
 
@@ -3,7 +3,7 @@
3
3
  module EPlat
4
4
  class Base < ActiveResource::Base
5
5
  include Concerns::OverwriteRequestMethods, Concerns::OverwriteInstanceMethods
6
- include Concerns::Aliases, Concerns::Dirty
6
+ include Concerns::Aliases, Concerns::Dirty, Concerns::FullJson
7
7
 
8
8
  self.connection_class = EPlat::Connection
9
9
  self.collection_parser = EPlat::Collection
@@ -0,0 +1,28 @@
1
+ module EPlat
2
+ module Concerns
3
+ module FullJson
4
+ extend ActiveSupport::Concern
5
+
6
+ def to_full_json # '{}'
7
+ as_full_json.to_json
8
+ end
9
+
10
+ def as_full_json # {}
11
+ self.attributes.each_with_object({}) do |(key, value), result|
12
+ result[key] =
13
+ case
14
+ when value.is_a?(EPlat::Base)
15
+ value.as_full_json
16
+ when value.is_a?(Array)
17
+ value.map do |v|
18
+ v.is_a?(EPlat::Base) ? v.as_full_json : v
19
+ end
20
+ else
21
+ value
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -5,8 +5,6 @@ module EPlat
5
5
  module Metafieldable #< ActiveResource::CustomMethods
6
6
 
7
7
  def metafields(**options)
8
- options.merge!(resource: self.class.collection_name, resource_id: id)
9
-
10
8
  Metafield.find(:all,
11
9
  from: current_resources_metafield_path,
12
10
  params: options
@@ -29,7 +29,7 @@ module EPlat
29
29
  super
30
30
  end
31
31
 
32
- def new(attributes, persisted = false)
32
+ def new(attributes={}, persisted = false)
33
33
  initialize_singleton!
34
34
 
35
35
  self.mapping = EPlat::Mapping.new_instance(specifc_mapping: specifc_mapping_name, resource: nil)
@@ -17,7 +17,7 @@ module EPlat
17
17
 
18
18
  if type.nil?
19
19
  return value
20
- elsif value.nil?
20
+ elsif value.nil? or value == "null"
21
21
  return unless type == "array" or type == "hash"
22
22
  end
23
23
 
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e_plat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-02 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -248,6 +248,7 @@ files:
248
248
  - lib/e_plat/resource/collection.rb
249
249
  - lib/e_plat/resource/concerns/aliases.rb
250
250
  - lib/e_plat/resource/concerns/dirty.rb
251
+ - lib/e_plat/resource/concerns/full_json.rb
251
252
  - lib/e_plat/resource/concerns/metafieldable.rb
252
253
  - lib/e_plat/resource/concerns/overwrite_instance_methods.rb
253
254
  - lib/e_plat/resource/concerns/overwrite_request_methods.rb