Sha256: 8d73403edbe312dc50cbb47846371b069f6ee493d9a135d46d4c3919c28a5c7f
Contents?: true
Size: 950 Bytes
Versions: 26
Compression:
Stored size: 950 Bytes
Contents
# frozen_string_literal: true module Motor class Query < ::Motor::ApplicationRecord audited belongs_to :author, polymorphic: true, optional: true has_many :taggable_tags, as: :taggable, dependent: :destroy has_many :tags, through: :taggable_tags, class_name: 'Motor::Tag' has_many :alerts, dependent: :destroy attribute :preferences, default: -> { ActiveSupport::HashWithIndifferentAccess.new } if Rails.version.to_f >= 7.1 serialize :preferences, coder: HashSerializer else serialize :preferences, HashSerializer end scope :active, -> { where(deleted_at: nil) } def result(variables_hash = {}) result = Motor::Queries::RunQuery.call!(self, variables_hash: variables_hash) column_names = result.columns.pluck(:name) result.data.map { |row| column_names.zip(row).to_h } end alias run result end end ActiveSupport.run_load_hooks(:motor_query, Motor::Query)
Version data entries
26 entries across 26 versions & 4 rubygems