sutty/app/models/concerns/tienda.rb
2020-11-11 18:15:58 -03:00

24 lines
481 B
Ruby

# frozen_string_literal: true
# Integración con la tienda
module Tienda
extend ActiveSupport::Concern
included do
encrypts :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