summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/permitted_attributes.rb
blob: d9ec072f7de7df413e716dc0d7606af683be8c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

# This module is responsible for managing what attributes can be updated
# through the api. It also overrides Spree::Permitted attributes to allow the
# solidus api to accept nested params for subscription models as well
module SolidusSubscriptions
  module PermittedAttributes
    class << self
      def subscription_line_item_attributes
        [SolidusSubscriptions.configuration.subscription_line_item_attributes]
      end

      def subscription_attributes
        SolidusSubscriptions.configuration.subscription_attributes | [
          line_items_attributes: (subscription_line_item_attributes | [:id] - [:subscribable_id]),
        ]
      end
    end
  end
end