2014-07-21 21:42:30 +00:00
module JamRuby
class GenericState < ActiveRecord :: Base
2020-05-09 13:22:19 +00:00
2021-04-21 21:27:55 +00:00
attr_accessible :top_message , :event_page_top_logo_url , :connection_policy , :customer_ltv , as : :admin
2020-05-09 13:22:19 +00:00
2014-07-21 21:42:30 +00:00
self . table_name = 'generic_state'
2014-07-31 02:05:59 +00:00
validates :env , :inclusion = > { :in = > [ 'development' , 'staging' , 'production' , 'test' ] }
2020-12-18 23:22:12 +00:00
validates :connection_policy , json : true
2014-07-30 21:39:59 +00:00
2014-08-18 15:37:55 +00:00
def self . env
GenericState . singleton . env
end
2014-07-30 21:39:59 +00:00
def self . allow_emails?
2014-07-31 02:05:59 +00:00
database_environment = singleton . env
2014-07-30 21:39:59 +00:00
# if the database says we are in production/staging, then the config has to also agree and say we are in production/staging to send emails
# this is to protect against developers loading a staging or production environment and possibly sending emails to
# we even go one step further, and make sure ENV['BUILD_NUMBER'] is set, which is something you do in production, but would be very rare in development
# or if your database says 'development' and config say 'development', then we allow emails to go out too
( ! ENV [ 'BUILD_NUMBER' ] . nil? && ( Environment . mode == 'production' || Environment . mode == 'staging' ) && ( database_environment == 'production' || database_environment == 'staging' ) ) ||
( database_environment == 'development' && Environment . mode == 'development' )
end
2015-05-28 13:20:14 +00:00
def self . affiliate_tallied_at
GenericState . singleton . affiliate_tallied_at
end
2016-01-04 20:44:45 +00:00
def self . bounce_check_at
GenericState . singleton . bounce_check_at
end
2020-05-09 13:22:19 +00:00
def self . top_message
GenericState . singleton . top_message
end
2020-09-19 16:52:31 +00:00
def self . event_page_top_logo_url
GenericState . singleton . event_page_top_logo_url
end
2021-02-15 04:32:27 +00:00
def self . recurly_transactions_last_sync_at
GenericState . singleton . recurly_transactions_last_sync_at
end
2021-04-21 21:27:55 +00:00
def self . customer_ltv
GenericState . singleton . customer_ltv
end
2020-12-18 23:22:12 +00:00
def self . connection_policy
GenericState . connection_policy
end
2014-07-21 21:42:30 +00:00
def self . singleton
GenericState . find ( 'default' )
end
end
end