Module: MessageTrain::ClassMethods
- Defined in:
- lib/message_train/class_methods.rb
Overview
Extended when message_train mixin is run
Instance Method Summary collapse
- #collective? ⇒ Boolean
- #find_by_message_train_slug(slug) ⇒ Object
- #message_train_address_book(for_participant) ⇒ Object
- #name_column ⇒ Object
- #slug_column ⇒ Object
- #valid_recipients_method ⇒ Object
- #valid_senders_method ⇒ Object
- #where_slug_starts_with(string) ⇒ Object
Instance Method Details
#collective? ⇒ Boolean
47 48 49 |
# File 'lib/message_train/class_methods.rb', line 47 def collective? valid_senders_method != :self_collection end |
#find_by_message_train_slug(slug) ⇒ Object
16 17 18 |
# File 'lib/message_train/class_methods.rb', line 16 def (slug) find_by(slug_column => slug.strip) end |
#message_train_address_book(for_participant) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/message_train/class_methods.rb', line 4 def (for_participant) method = MessageTrain.configuration.address_book_methods[ ] method ||= MessageTrain.configuration.address_book_method if method.present? && respond_to?(method) send(method, for_participant) else all end end |
#name_column ⇒ Object
31 32 33 |
# File 'lib/message_train/class_methods.rb', line 31 def name_column MessageTrain.configuration.name_columns[] || :name end |
#slug_column ⇒ Object
27 28 29 |
# File 'lib/message_train/class_methods.rb', line 27 def slug_column MessageTrain.configuration.slug_columns[] || :slug end |
#valid_recipients_method ⇒ Object
41 42 43 44 45 |
# File 'lib/message_train/class_methods.rb', line 41 def valid_recipients_method MessageTrain.configuration .valid_recipients_methods[] || :self_collection end |
#valid_senders_method ⇒ Object
35 36 37 38 39 |
# File 'lib/message_train/class_methods.rb', line 35 def valid_senders_method MessageTrain.configuration .valid_senders_methods[] || :self_collection end |
#where_slug_starts_with(string) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/message_train/class_methods.rb', line 20 def where_slug_starts_with(string) return where(nil) unless string.present? pattern = Regexp.union('\\', '%', '_') string = string.gsub(pattern) { |x| ['\\', x].join } where("#{slug_column} LIKE ?", "#{string}%") end |