<commit_before>module TransForms
  module MainModel
    module Proxy
      extend ActiveSupport::Concern
      # A module that adds functionality to delegate certain
      # methods to the main model. This is done to make forms
      # and controllers handle the form model as if it were
      # the main model itself

      def persisted?
        respond_to?(:main_instance) && main_instance && main_instance.persisted?
      end

      # Returns an Enumerable of all key attributes of the main instanceif any is
      # set, regardless if the object is persisted or not. Returns +nil+ if there
      # is no main_instance or if main_instance have no key attributes.
      #
      #   class UserForm < TransForms::BaseForm
      #     set_main_model :user, proxy: true
      #   end
      #
      #   form = UserForm.new
      #   form.to_key # => nil
      #
      #   form.user = User.new<commit_msg>Added to_param method to Proxy module<commit_after>module TransForms
  module MainModel
    module Proxy
      extend ActiveSupport::Concern
      # A module that adds functionality to delegate certain
      # methods to the main model. This is done to make forms
      # and controllers handle the form model as if it were
      # the main model itself

      def persisted?
        respond_to?(:main_instance) && main_instance && main_instance.persisted?
      end

      # In case the Main Model has implemented custom +to_param+ method, we need
      # to make sure we use it here as well
      def to_param
        respond_to?(:main_instance) && main_instance && main_instance.to_param || super
      end

      # Returns an Enumerable of all key attributes of the main instanceif any is
      # set, regardless if the object is persisted or not. Returns +nil+ if there
      # is no main_instance or if main_instance have no key attributes.
      #
      #   class UserForm < TransForms::BaseForm
      #     set_main_model :user, proxy: true
      #   end
      #
      #   form = UserForm.new
      #   form.to_key # => nil
      #
      #   form.user = User.new
{'fraction_non_alphanumeric': 0.05885190545103714, 'fraction_numerical': 0.0, 'mean_word_length': 2.372357723577236, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3086405', 'n_tokens_mistral': 564, 'n_tokens_neox': 548, 'n_words': 226}