Class: WcoEmail::EmailFilter
- Inherits:
-
Object
- Object
- WcoEmail::EmailFilter
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/wco_email/email_filter.rb
Constant Summary collapse
- PAGE_PARAM_NAME =
:filters_page- STATUS_ACTIVE =
'active'- STATUS_INACTIVE =
'inactive'
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.active ⇒ Object
14 |
# File 'app/models/wco_email/email_filter.rb', line 14 def self.active; where( :status.in => [ nil, STATUS_ACTIVE ] ); end |
Instance Method Details
#to_s ⇒ Object
42 43 44 |
# File 'app/models/wco_email/email_filter.rb', line 42 def to_s "EmailFilter (#{conditions.length}) `#{slug}`" end |
#to_s_full ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/wco_email/email_filter.rb', line 45 def to_s_full attrs = '' out =<<-AOL <EmailFilter#{attrs} > #{conditions.map { |c| c.to_s_full( indent: 2) }.join } #{skip_conditions.map { |c| c.to_s_full( indent: 2) }.join } #{actions.map { |c| c.to_s_full( indent: 2) }.join } </EmailFilter> AOL while out.match(/\n\n/) do out = out.gsub(/\n\n/, "\n") end out end |
#validate_actions ⇒ Object
19 20 21 22 23 |
# File 'app/models/wco_email/email_filter.rb', line 19 def validate_actions if actions.length == 0 errors.add(:actions, 'must be present') end end |
#validate_conditions ⇒ Object
28 29 30 31 32 |
# File 'app/models/wco_email/email_filter.rb', line 28 def validate_conditions if conditions.length == 0 errors.add(:condition, 'must be present') end end |