ActiveRecordService -------------------
503535
protected static function applyPublicFilters( $config ) {

		$modelClass	= static::$modelClass;
		$modelTable = $modelClass::tableName();

		// Public models
		$public		= isset( $config[ 'public' ] ) ? $config[ 'public' ] : false;
		$status		= isset( $config[ 'filterStatus' ] ) ? $config[ 'filterStatus' ] : true;
		$visibility = isset( $config[ 'filterVisibility' ] ) ? $config[ 'filterVisibility' ] : true;

		if( $public ) {

			$interfaces = class_implements( $modelClass );

			// Select only active and frozen models excluding new, blocked and terminated models.
			if( $status && isset( $interfaces[ 'cmsgears\core\common\models\interfaces\base\IApproval' ] ) ) {

				$config[ 'filters' ][] = [ 'in', "$modelTable.status", [ IApproval::STATUS_ACTIVE, IApproval::STATUS_FROJEN ] ];
			}

			// Select only publicly visible models
			if( $visibility && isset( $interfaces[ 'cmsgears\core\common\models\interfaces\base\IVisibility' ] ) ) {

				$config[ 'conditions' ][ "$modelTable.visibility" ]	= IVisibility::VISIBILITY_PUBLIC;
			}
		}

		return $config;
	}
809717
function current (args) {
    // build args
    var queryArgs = {
        current: true,
        limit: 1,
        where: {
            id: this.id,
        },
        session: this.session,
    }
    // override with args if passed
    if (defined(args)) {
        _.merge(queryArgs, args)
    }
    // do query for current record
    return this.model.query(queryArgs)
}
839649
def dump(records, dump = '')
      # each is faster than inject
      records.each do |record|
        record[1] = @serializer.dump(record.last)
        dump << @format.dump(record)
      end
      dump
    end
1289464
def nested_records_changed_for_autosave?
      self.class.reflect_on_all_autosave_associations.any? do |reflection|
        association = association_instance_get(reflection.name)
        association && Array.wrap(association.target).any? { |a| a.changed_for_autosave? }
      end
    end
898353
def awesome_active_model_error(object)
      return object.inspect if !defined?(::ActiveSupport::OrderedHash)
      return awesome_object(object) if @options[:raw]

      object_dump = object.marshal_dump.first
      data = if object_dump.class.column_names != object_dump.attributes.keys
               object_dump.attributes
             else
               object_dump.class.column_names.inject(::ActiveSupport::OrderedHash.new) do |hash, name|
                 if object_dump.has_attribute?(name) || object_dump.new_record?
                   value = object_dump.respond_to?(name) ? object_dump.send(name) : object_dump.read_attribute(name)
                   hash[name.to_sym] = value
                 end
                 hash
               end
             end

      data.merge!({details: object.details, messages: object.messages})
      "#{object} " << awesome_hash(data)
    end
233162
public function syncActiveRecord( $serviceName = null, ActiveRecord $model ) {

        $service = $this->getService( $serviceName );

        if ( $service->isConnected() && ! $this->isExistsSyncModelByActiveRecord( $service, $model ) ) {

            $message  = $model->{$this->modelAttribute};
            $function = $this->absolutePostUrl;

            $url = null;
            if ( is_callable( $function ) && ( $function instanceof Closure ) ) {
                $url = $function( $serviceName, $model->getPrimaryKey() );
            }

            $publishData = $service->publishPost( $message, $url );

            return $this->checkPostData( $publishData ) && $this->createSyncModel( $service, $model, $publishData );

        } else {
            return false;
        }
    }
1228734
def fields_for record_name, record_object = nil, fields_options = {}, &block
      super record_name, record_object, fields_options.merge(builder: self.class), &block
    end
1144095
static QueryMeta buildFindSql(ActiveRecord activeRecord) {
        QueryMeta queryMeta = new QueryMeta();
        String    initSql   = parseFieldsSql(activeRecord.getTableName(), null);

        StringBuilder sqlBuf = new StringBuilder(initSql);

        int[] pos = {1};
        // 解析尸体设置的
        List<Object> list = parseWhere(activeRecord, pos, sqlBuf);
        List<Object> temp = andWhere(activeRecord, pos, sqlBuf);
        if (null != temp) {
            list.addAll(temp);
        }

        String sql = sqlFilter(sqlBuf.toString());
        queryMeta.setSql(sql);
        queryMeta.setParams(list.toArray());
        mapping(queryMeta, activeRecord.getClass());
        return queryMeta;
    }
907645
static QueryMeta buildCountSql(ActiveRecord activeRecord) {
        QueryMeta     queryMeta = new QueryMeta();
        StringBuilder sqlBuf    = new StringBuilder("SELECT COUNT(*) FROM " + activeRecord.getTableName());
        int[]         pos       = {1};
        List<Object>  list      = parseWhere(activeRecord, pos, sqlBuf);

        List<Object> temp = andWhere(activeRecord, pos, sqlBuf);
        if (null != temp) {
            list.addAll(temp);
        }

        String   sql  = sqlFilter(sqlBuf.toString());
        Object[] args = list.toArray();
        queryMeta.setSql(sql);
        queryMeta.setParams(args);
        return queryMeta;
    }
1330001
public function onYiiEvent()
    {
        Event::on(ActiveRecord::className(), ActiveRecord::EVENT_INIT, function ($event) {
            /** @var ActiveRecord $model */
            $model = $event->sender;
            $model->getTableSchema();
        });
    }
1276360
def create_or_find_by!(attributes, &block)
      transaction(requires_new: true) { create!(attributes, &block) }
    rescue ActiveRecord::RecordNotUnique
      find_by!(attributes)
    end
1090805
def save_records
      unless @records.empty?
        @model_class.connection.populate(@model_class.quoted_table_name, columns_sql, rows_sql_arr, "#{@model_class.name} Populate")
        @last_id_in_database = @records.last.id
        @records.clear
      end
    end
394304
def reload
      if new_record?
        false
      else
        reloaded_element = self.class.find(self.id)
        @attributes = reloaded_element.attributes
        reset_modifications
        true
      end
    end
1159277
function(records,config) {
    
    //the hell is this doing here
    this.id = new Date();

    if ( records instanceof Array ) {
        this.records = records;
    } else {
        var dataField = records.data;
        var data = records.datasource;
        this.records =  data[dataField];
    }
    this.config = config;
    if ( this.config ) {
        this.propertyConfigMap = {};
        this.config.cols.forEach( col => {
            this.propertyConfigMap[col.property] = col;
        });
    }

    //indexRecords.call(this);
}
1259406
def obtain_record(check = nil, type = nil)
      
      return check if check.is_a?(ActiveRecord::Base)

      if check.blank? 
        return nil if @content.blank? || !@content[0].blank?
        @content
      else
        records = Post.where( 'post_title = :p OR post_slug = :p2 OR id = :p3', { p: check.to_s, p2: check.to_s, p3: check.to_i} )
        if !type.blank?
          records = records.where("post_type = :p4", {p4: type})
        end
        records.first
      end

    end
146648
def associated_records_to_validate_or_save(association,
                                               new_record,
                                               autosave)
      if new_record || autosave
        association && association.target
      else
        association.target.find_all(&:new_record?)
      end
    end
773465
function ( query, associations ) {
		_.each( associations, function ( assoc ) {
			// if the associations is to be populated with the full records...
			if ( assoc.include === "record" ) query.populate( assoc.alias );
		} );
		return query;
	}