<commit_before>module WulinMaster
  class Screen

    cattr_accessor :screens

    # subclass inherited
    def self.inherited(subclass)
      # add new subclass screen to screens pool
      self.screens ||= []
      self.screens << subclass unless self.screens.include?(subclass)

      # ???
      subclass.send :include, Rails.application.routes.url_helpers

      Rails.logger.info "Screen #{subclass} loaded"
    end

    # ---------------------- metaclass, define some DSL methods -------------------------------
    class << self
      #alias_method :all, :screens
      attr_reader :title, :path, :grid_configs
      attr_accessor :controller_class

      def title(new_title=nil)
        new_title ? @title = new_title : @title || self.to_s.gsub(/Screen/, "")
      end

      def path(new_path=nil)
        new_path ? @path = new_path : @path || self.title.tableize
        # TODO
        # in last circle of refactoring, the screen path can be the same-named action path of screens_controller
      end

      # Add a grid config to a screen
      def grid(klass, options={})        
        @grid_configs ||= []
        @grid_configs << {class: klass}.merge(options) if klass
      end
    end

    # -------------------------------- Instance methods ---------------------------------------
    attr_accessor :grids, :controller, :params
    
    def initialize(params={}, controller_instance=nil)
      @controller = controller_instance<commit_msg>MISC - Improved screen class method path, get more accurate path<commit_after>module WulinMaster
  class Screen

    cattr_accessor :screens

    # subclass inherited
    def self.inherited(subclass)
      # add new subclass screen to screens pool
      self.screens ||= []
      self.screens << subclass unless self.screens.include?(subclass)

      # ???
      subclass.send :include, Rails.application.routes.url_helpers

      Rails.logger.info "Screen #{subclass} loaded"
    end

    # ---------------------- metaclass, define some DSL methods -------------------------------
    class << self
      #alias_method :all, :screens
      attr_reader :title, :path, :grid_configs
      attr_accessor :controller_class

      def title(new_title=nil)
        new_title ? @title = new_title : @title || self.to_s.gsub(/Screen/, "")
      end

      def path(new_path=nil)
        new_path ? @path = new_path : @path || self.to_s.gsub(/Screen/, "").underscore.pluralize
        # TODO
        # in last circle of refactoring, the screen path can be the same-named action path of screens_controller
      end

      # Add a grid config to a screen
      def grid(klass, options={})        
        @grid_configs ||= []
        @grid_configs << {class: klass}.merge(options) if klass
      end
    end

    # -------------------------------- Instance methods ---------------------------------------
    attr_accessor :grids, :controller, :params
    
    def initialize(params={}, controller_instance=nil)
      @controller = controller_instance
{'fraction_non_alphanumeric': 0.17016317016317017, 'fraction_numerical': 0.0, 'mean_word_length': 1.9890547263681593, 'pattern_counts': {'":': 0, '<': 15, '<?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': '3083279', 'n_tokens_mistral': 833, 'n_tokens_neox': 816, 'n_words': 225}