<commit_before>module Spree
  class Digital < ActiveRecord::Base
    belongs_to :variant
    has_many :digital_links, dependent: :destroy
    has_many :drm_records, dependent: :destroy

    has_attached_file :attachment, path: ":rails_root/private/digitals/:id/:basename.:extension"
    do_not_validate_attachment_file_type :attachment
    validates_attachment_presence :attachment

    if Paperclip::Attachment.default_options[:storage] == :s3
      attachment_definitions[:attachment][:s3_permissions] = :private
      attachment_definitions[:attachment][:s3_headers] = { content_disposition: 'attachment' }
    end

    def cloud?
      Paperclip::Attachment.default_options[:storage] == :s3
    end

    def create_drm_record(line_item)
      drm_records.create!(line_item: line_item)
    end
  end
end<commit_msg>Support setting the storage not using default_options<commit_after>module Spree
  class Digital < ActiveRecord::Base
    belongs_to :variant
    has_many :digital_links, dependent: :destroy
    has_many :drm_records, dependent: :destroy

    has_attached_file :attachment, path: ":rails_root/private/digitals/:id/:basename.:extension"
    do_not_validate_attachment_file_type :attachment
    validates_attachment_presence :attachment

    if Paperclip::Attachment.default_options[:storage] == :s3 || attachment_definitions[:attachment][:storage] == :s3
      attachment_definitions[:attachment][:s3_permissions] = :private
      attachment_definitions[:attachment][:s3_headers] = { content_disposition: 'attachment' }
    end

    def cloud?
      attachment.options[:storage] == :s3
    end

    def create_drm_record(line_item)
      drm_records.create!(line_item: line_item)
    end
  end
end
{'fraction_non_alphanumeric': 0.09515469935785172, 'fraction_numerical': 0.005253940455341506, 'mean_word_length': 4.97212543554007, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3597354', 'n_tokens_mistral': 513, 'n_tokens_neox': 505, 'n_words': 95}