app/models/solidus_subscriptions/subscription_generator.rb
def activate(subscription_line_items)
      return if subscription_line_items.empty?

      order = subscription_line_items.first.order
      configuration = subscription_configuration(subscription_line_items.first)

      subscription_attributes = {
        user: order.user,
        line_items: subscription_line_items,
        store: order.store,
        shipping_address: order.ship_address,
        **configuration.to_h
      }

      Subscription.create!(subscription_attributes) do |sub|
        sub.actionable_date = sub.next_actionable_date
      end
    end
# Create and persist a subscription for a collection of subscription
#   line items
#
# @param subscription_line_items [Array<SolidusSubscriptions::LineItem>] The
#   subscription_line_items to be activated
#
# @return [SolidusSubscriptions::Subscription]
Create and persist a subscription for a collection of subscription
line items
Create and persist a subscription for a collection of subscription line items
def activate(subscription_line_items)
      return if subscription_line_items.empty?
      order = subscription_line_items.first.order
      configuration = subscription_configuration(subscription_line_items.first)
      subscription_attributes = {
        user: order.user,
        line_items: subscription_line_items,
        store: order.store,
        shipping_address: order.ship_address,
        **configuration.to_h
      }
      Subscription.create!(subscription_attributes) do |sub|
        sub.actionable_date = sub.next_actionable_date
      end
    end
def activate ( subscription_line_items ) return if subscription_line_items . empty? order = subscription_line_items . first . order configuration = subscription_configuration ( subscription_line_items . first ) subscription_attributes = { user : order . user , line_items : subscription_line_items , store : order . store , shipping_address : order . ship_address , ** configuration . to_h } Subscription . create! ( subscription_attributes ) do | sub | sub . actionable_date = sub . next_actionable_date end end
Create and persist a subscription for a collection of subscription
line items
Create and persist a subscription for a collection of subscription line items
None
SolidusSubscriptions::Subscription
subscription_line_items
The subscription_line_items to be activated
The subscription_line_items to be activated