Sha256: 02251773da48a9d0daa2ef619ce5130f7e4b36ea9ad0879e773e6e473025bc8f
Contents?: true
Size: 926 Bytes
Versions: 25
Compression:
Stored size: 926 Bytes
Contents
# frozen_string_literal: true module Motor class ApiConfig < ::Motor::ApplicationRecord encrypts :credentials if defined?(::Motor::EncryptedConfig) attribute :preferences, default: -> { ActiveSupport::HashWithIndifferentAccess.new } attribute :credentials, default: -> { ActiveSupport::HashWithIndifferentAccess.new } if Rails.version.to_f >= 7.1 serialize :credentials, coder: Motor::HashSerializer serialize :preferences, coder: Motor::HashSerializer else serialize :credentials, Motor::HashSerializer serialize :preferences, Motor::HashSerializer end has_one :form, dependent: nil, foreign_key: :api_config_name, primary_key: :name, inverse_of: :api_config scope :active, -> { where(deleted_at: nil) } def headers credentials.fetch(:headers, []).each_with_object({}) do |item, acc| acc[item[:key]] = item[:value] end end end end
Version data entries
25 entries across 25 versions & 4 rubygems