<commit_before>require "datagrid/drivers"
require "active_support/core_ext/class/attribute"

module Datagrid
  module Core

    def self.included(base)
      base.extend         ClassMethods
      base.class_eval do
        class_attribute :scope_value

        class_attribute :datagrid_attributes
        self.datagrid_attributes = []

        class_attribute :dynamic_block, :instance_writer => false
      end
      base.send :include, InstanceMethods
    end # self.included

    module ClassMethods

      def datagrid_attribute(name, &block) #:nodoc:
        unless datagrid_attributes.include?(name)
          block ||= lambda do |value|
            value
          end
          datagrid_attributes << name
          define_method name do
            instance_variable_get("@#{name}")
          end

          define_method :"#{name}=" do |value|
            instance_variable_set("@#{name}", instance_exec(value, &block))
          end
        end
      end

      # Defines a scope at class level
      def scope(&block)
        if block
          current_scope = scope_value<commit_msg>Use Rails attributes assignment if available<commit_after>require "datagrid/drivers"
require "active_support/core_ext/class/attribute"

module Datagrid
  module Core

    def self.included(base)
      base.extend         ClassMethods
      base.class_eval do
        class_attribute :scope_value

        class_attribute :datagrid_attributes
        self.datagrid_attributes = []

        class_attribute :dynamic_block, :instance_writer => false
        if defined?(::ActiveModel::AttributeAssignment)
          include ::ActiveModel::AttributeAssignment
        end
      end
      base.send :include, InstanceMethods
    end # self.included

    module ClassMethods

      def datagrid_attribute(name, &block) #:nodoc:
        unless datagrid_attributes.include?(name)
          block ||= lambda do |value|
            value
          end
          datagrid_attributes << name
          define_method name do
            instance_variable_get("@#{name}")
          end

          define_method :"#{name}=" do |value|
            instance_variable_set("@#{name}", instance_exec(value, &block))
          end
        end
      end

      # Defines a scope at class level
      def scope(&block)
        if block
          current_scope = scope_value
{'fraction_non_alphanumeric': 0.07708688245315162, 'fraction_numerical': 0.0, 'mean_word_length': 2.276150627615063, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6773825', 'n_tokens_mistral': 637, 'n_tokens_neox': 630, 'n_words': 153}