Sha256: 9cf0f8726940ea9161eacb618f3124b6b7667abc5e28391cff27374e47161d89
Contents?: true
Size: 742 Bytes
Versions: 5
Compression:
Stored size: 742 Bytes
Contents
module Workarea decorate User, with: :mail_chimp do class_methods do def default_groups Workarea::MailChimp.gateway.interests end end decorated do before_validation :check_email_signup before_save :default_groups_if_empty field :email_signup, type: Boolean, default: false embeds_many :groups, class_name: "Workarea::MailChimp::Group" end private def check_email_signup self.email_signup ||= Workarea::Email.signed_up?(self.email) end def default_groups_if_empty return unless has_attribute?("email_signup") if self.groups.empty? && self.email_signup? self.groups = User.default_groups end end end end
Version data entries
5 entries across 5 versions & 1 rubygems