izi_json_ld 1.0.10 → 1.0.11

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
  SHA1:
3
- metadata.gz: 8460fc684cdf425df5ab3eb1c37cf3cec4fd94ce
4
- data.tar.gz: ebe42ecc6dd75499a3d4c7d64011652ecd2a44be
3
+ metadata.gz: dcc874ab5405c6e7f56fc9bde4bec4e288b44831
4
+ data.tar.gz: a2f871bd7e3a815180c17a2395a1e4744e0a54bf
5
5
  SHA512:
6
- metadata.gz: 1ce55344a93dc3e3ddfa65dc5387d48e5fc8af0f65ab072378de5764e37f7b9c52d966c18931a103631e919a1d984c3bbe67065a223fbad0ed4f9b9cb224d6d7
7
- data.tar.gz: 8175939a4405a80fe70cad66c8e7e25b4007483123cf76027656eb752389fb989691abb039d22956ce0d68694e4e739759c1263bdf0ff4cc8db120c1c1fc1638
6
+ metadata.gz: d6cc1e6e99a9e7a40d82ee84d0499bd3e39f2743e268e1d403feab724351847e4e3f84fa9b2e7f04a0b00a058604ed811a13042e62674c17bdfbc6a2fa7080f9
7
+ data.tar.gz: 582a5dc61fb74a9db7dd4c61058bf7c0e0e3f5b83ea91de48312c3e27c9c4fa04c76b0c90d2a9d800ba85926922fd123675c4980ef0d7e8b91f7188667d6c757
@@ -4,11 +4,29 @@ class ProductEntity < ApplicationEntity
4
4
  type 'Product'
5
5
 
6
6
  attribute :name, ::IziJsonLd::Types::String
7
- attribute? :brand, ::IziJsonLd::Types::String.optional
7
+ attribute? :brand, (::IziJsonLd::Types::Strict::String | ::OrganizationEntity).optional
8
8
  attribute? :image, ::IziJsonLd::Types::String.optional
9
9
  attribute? :description, ::IziJsonLd::Types::String.optional
10
+ attribute? :sku, ::IziJsonLd::Types::String.optional
11
+ attribute? :gtin, ::IziJsonLd::Types::String.optional
12
+ attribute? :mpn, ::IziJsonLd::Types::String.optional
10
13
 
11
14
  attribute? :offers, OfferEntity.optional
12
15
  attribute? :aggregateRating, AggregateRatingEntity.optional
13
16
  attribute? :review, ::IziJsonLd::Types::OneOrMore[::ReviewEntity].optional
17
+
18
+ def dump_attributes
19
+ attributes.except(:brand).merge(
20
+ brand: safe_brand
21
+ )
22
+ end
23
+
24
+ private
25
+
26
+ def safe_brand
27
+ return if brand.blank?
28
+ return brand unless brand.is_a?(String)
29
+
30
+ ::OrganizationEntity.new(name: brand)
31
+ end
14
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IziJsonLd
4
- VERSION = '1.0.10'
4
+ VERSION = '1.0.11'
5
5
  end