<commit_before># Makes certain AR Model methods available to the view model.
#
# Useful when the model is an AR Model.
#
module ViewModels
  module Extensions
    module RenderOptions
      
      attr_accessor :path, :name, :prefix
      
      #
      #
      def partial= name
        self.prefix = :'_'
        self.template_name = name
      end
      #
      #
      def template= name
        self.prefix = nil
        self.template_name = name
      end
      
      #
      #
      def view_model= view_model
        self[:locals] = { :view_model => view_model }.merge self[:locals] || {}
      end
      
      #
      #
      def template_name= template_name
        template_name = deoptionize template_name
        template_name.to_s.include?('/') ? specific_path(template_name) : incomplete_path(template_name)
      end
      
      private
        
        #
        #
        def deoptionize template_name
          if template_name.kind_of?(Hash)
            self.merge! template_name
            self.delete :partial
          else
            template_name
          end
        end
        
        #
        #
        def specific_path name
          self.path = File.dirname name
          self.name = "#{self.prefix}#{File.basename(name)}"
        end
        
        #
        #
        def incomplete_path name
          self.path = nil
          self.name = "#{self.prefix}#{name}"
        end
        
    end
  end
end<commit_msg>+ method extraction<commit_after># Makes certain AR Model methods available to the view model.
#
# Useful when the model is an AR Model.
#
module ViewModels
  module Extensions
    module RenderOptions
      
      attr_accessor :path, :name, :prefix
      
      #
      #
      def partial= name
        self.prefix = :'_'
        self.template_name = name
      end
      #
      #
      def template= name
        self.prefix = nil
        self.template_name = name
      end
      
      #
      #
      def view_model= view_model
        self[:locals] = { :view_model => view_model }.merge self[:locals] || {}
      end
      
      #
      #
      def template_name= template_name
        template_name = deoptionize template_name
        specific_path?(template_name) ? specific_path(template_name) : incomplete_path(template_name)
      end
      
      private
        
        #
        #
        def deoptionize template_name
          if template_name.kind_of?(Hash)
            self.merge! template_name
            self.delete :partial
          else
            template_name
          end
        end
        
        #
        #
        def specific_path? template_name
          template_name.to_s.include? '/'
        end
        
        #
        #
        def specific_path name
          self.path = File.dirname name
          self.name = "#{self.prefix}#{File.basename(name)}"
        end
        
        #
        #
        def incomplete_path name
          self.path = nil
          self.name = "#{self.prefix}#{name}"
        end
        
    end
  end
end
{'fraction_non_alphanumeric': 0.07581227436823104, 'fraction_numerical': 0.0, 'mean_word_length': 1.4152139461172741, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4490474', 'n_tokens_mistral': 859, 'n_tokens_neox': 860, 'n_words': 200}