Sha256: 9d5d6daf9d42ba96e96695259fbbef0bf35c051673d486e2c7ba613c02b19c91
Contents?: true
Size: 962 Bytes
Versions: 5
Compression:
Stored size: 962 Bytes
Contents
module Unidom::Contact::Concerns::AsSubscriber extend ActiveSupport::Concern included do |includer| has_many :contact_subscriptions, class_name: 'Unidom::Contact::ContactSubscription', as: :subscriber def subscribe_contact!(contact, at: Time.now, name: nil, primary: true) raise ArgumentError.new('The contact argument is required.') if contact.blank? raise ArgumentError.new('The at argument is required.' ) if at.blank? contact_subscriptions.contact_is(contact).valid_at(now: at).alive.first_or_create! name: name||self.name, elemental: primary, opened_at: at end def subscribe_contact?(contact, at: Time.now, primary: true) raise ArgumentError.new('The contact argument is required.') if contact.blank? raise ArgumentError.new('The at argument is required.' ) if at.blank? contact_subscriptions.contact_is(contact).valid_at(now: at).alive.primary(primary).exists? end end end
Version data entries
5 entries across 5 versions & 1 rubygems