activity_notification 2.7.2 → 2.7.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: 9c4c8885cdeaf0c979ae2474e5ca5459a16e0f14c605fa5d2f0ad37076e7c793
4
- data.tar.gz: 267223c3dbc745920baabb75d5e936cafef5a3fbe2e301f46aab04ae9d6a34a8
3
+ metadata.gz: 47f4dd8ad07b61e91c1d44516461cf8bd348807ea1eeab0dd8ffdd76e549606e
4
+ data.tar.gz: 52249dfbf866444bdc81aacb4d2094e1e0eb30a6a28f387aa85d33f1ed533e3e
5
5
  SHA512:
6
- metadata.gz: bcb53649395b3e43ab8e3b4a043a40947305ee35cd15fe16a9737f16c866ff543749e78b00c5c5659d8a34eaf198a6c30b6933d29a048db00d56ea17b7c4694e
7
- data.tar.gz: cc390e51688280d2c84bb949814ae6a3ecad9f1c444066b45d91316d47fea5bb71a7dec03fd4a582d503cc5f7aad70e47c9c0f7ddf16b1da1f92ae1485c10595
6
+ metadata.gz: 9663a31226c9b1fb504122b4ee06da5e953bd48b80c5a9de4903c658e03279ecc1d49151a2fbffee1dc9ab4ff19f028bd0e78b103b34bf9d70a181453cbe94a9
7
+ data.tar.gz: ed5cc0ebfa1828953db40e8ba37f339999204035bd889a647d1afe5c2873cce5884ac024d5585ede035760145910ecd329d963656184db8122cc4e827db9f4d4
@@ -154,7 +154,7 @@ module ActivityNotification
154
154
  end
155
155
  {
156
156
  include: include_options,
157
- methods: [:notifiable_path, :printable_notifiable_name, :group_member_notifier_count, :group_notification_count]
157
+ methods: [:notifiable_path, :printable_notifiable_name, :group_member_notifier_count, :group_notification_count] + polymorphic_association_json_methods(ActivityNotification::Notification)
158
158
  }
159
159
  end
160
160
 
@@ -20,7 +20,7 @@ module ActivityNotification
20
20
  # @return [JSON] configured_count: count of subscription index, subscriptions: subscription index, unconfigured_count: count of unconfigured notification keys, unconfigured_notification_keys: unconfigured notification keys
21
21
  def index
22
22
  super
23
- json_response = { configured_count: @subscriptions.size, subscriptions: @subscriptions } if @subscriptions
23
+ json_response = { configured_count: @subscriptions.size, subscriptions: @subscriptions.as_json(include: subscription_json_include_option, methods: subscription_json_methods_option) } if @subscriptions
24
24
  json_response = (json_response || {}).merge(unconfigured_count: @notification_keys.size, unconfigured_notification_keys: @notification_keys) if @notification_keys
25
25
  render json: json_response
26
26
  end
@@ -180,7 +180,7 @@ module ActivityNotification
180
180
  # Returns methods option for subscription JSON
181
181
  # @api protected
182
182
  def subscription_json_methods_option
183
- [].freeze
183
+ polymorphic_association_json_methods(ActivityNotification::Subscription).freeze
184
184
  end
185
185
 
186
186
  # Returns JSON of @subscription
@@ -26,5 +26,16 @@ module ActivityNotification
26
26
  def redirect_to_subscription_path
27
27
  end
28
28
 
29
+ # Returns methods to add polymorphic association type and id to JSON of the model.
30
+ # Dynamoid models store polymorphic associations as composite keys (e.g. target_key),
31
+ # so their type and id are added to JSON responses as with other ORMs.
32
+ # @api protected
33
+ # @param [Class] model_class Model class of the JSON (e.g. ActivityNotification::Notification)
34
+ # @return [Array<Symbol>] Methods to add to JSON
35
+ def polymorphic_association_json_methods(model_class)
36
+ associations = ActivityNotification.config.orm == :dynamoid ? model_class._associated_composite_records : []
37
+ associations.flat_map { |association| [:"#{association}_type", :"#{association}_id"] }
38
+ end
39
+
29
40
  end
30
41
  end
@@ -1,3 +1,3 @@
1
1
  module ActivityNotification
2
- VERSION = "2.7.2"
2
+ VERSION = "2.7.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activity_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Yamazaki