<commit_before>require 'attachinary/utils'

module Attachinary
  module Extension
    module Base

      def has_attachment(scope, options={})
        attachinary options.merge(single: true, scope: scope)
      end

      def has_attachments(scope, options={})
        attachinary options.merge(single: false, scope: scope)
      end

    private
      def attachinary(options)
        options = Attachinary::Utils.process_options(options)

        attachinary_orm_definition(options)

        # attr_accessible :photo
        # attr_accessible :images
        attr_accessible :"#{options[:scope]}" if options[:accessible]

        # def photo?
        #   photo.present?
        # end
        # def images?
        #   images.present?
        # end
        define_method :"#{options[:scope]}?" do
          send(:"#{options[:scope]}").present?
        end

        # def photo_metadata
        #   options
        # end
        define_method :"#{options[:scope]}_metadata" do
          options
        end

        if options[:single]
          # def photo_url=(url)
          #   ...
          # end
          define_method :"#{options[:scope]}_url=" do |url|
            send(:"#{options[:scope]}=", Cloudinary::Uploader.upload(url, resource_type: "auto"))
          end

        else
          # def image_urls=(urls)
          #   ...
          # end
          define_method :"#{options[:singular]}_urls=" do |urls|
            send(:"#{options[:scope]}=", urls.map { |url| Cloudinary::Uploader.upload(url, resource_type: "auto") })
          end<commit_msg>adding the option to optional parameters to _url and _urls methods<commit_after>require 'attachinary/utils'

module Attachinary
  module Extension
    module Base

      def has_attachment(scope, options={})
        attachinary options.merge(single: true, scope: scope)
      end

      def has_attachments(scope, options={})
        attachinary options.merge(single: false, scope: scope)
      end

    private
      def attachinary(options)
        options = Attachinary::Utils.process_options(options)

        attachinary_orm_definition(options)

        # attr_accessible :photo
        # attr_accessible :images
        attr_accessible :"#{options[:scope]}" if options[:accessible]

        # def photo?
        #   photo.present?
        # end
        # def images?
        #   images.present?
        # end
        define_method :"#{options[:scope]}?" do
          send(:"#{options[:scope]}").present?
        end

        # def photo_metadata
        #   options
        # end
        define_method :"#{options[:scope]}_metadata" do
          options
        end

        if options[:single]
          # def photo_url=(url)
          #   ...
          # end
          define_method :"#{options[:scope]}_url=" do |url, upload_options = {}|
            upload_options.merge! resource_type: 'auto'
            send(:"#{options[:scope]}=", Cloudinary::Uploader.upload(url, upload_options))
          end

        else
          # def image_urls=(urls)
          #   ...
          # end
          define_method :"#{options[:singular]}_urls=" do |urls, upload_options = {}|
            upload_options.merge! resource_type: 'auto'
            send(:"#{options[:scope]}=", urls.map { |url| Cloudinary::Uploader.upload(url, upload_options) })
          end
{'fraction_non_alphanumeric': 0.12232600180777342, 'fraction_numerical': 0.0, 'mean_word_length': 2.123236124176858, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4905628', 'n_tokens_mistral': 931, 'n_tokens_neox': 927, 'n_words': 197}