5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 13:14:18 +00:00
panel/app/models/concerns/tienda.rb
2024-05-02 16:05:35 -03:00

24 lines
481 B
Ruby

# frozen_string_literal: true
# Integración con la tienda
module Tienda
extend ActiveSupport::Concern
included do
has_encrypted :tienda_api_key
def tienda?
tienda_api_key.present? && tienda_url.present?
end
# Sugerir una dirección al configurar por primera vez
def tienda_url
t = read_attribute(:tienda_url)
return t if new_record?
t.blank? ? "https://#{name}.#{ENV.fetch('TIENDA', 'tienda.sutty.nl')}" : t
end
end
end