Module: Maktoub
- Defined in:
- lib/maktoub.rb,
lib/maktoub/engine.rb,
lib/maktoub/version.rb,
app/helpers/maktoub/archives_helper.rb,
app/mailers/maktoub/newsletter_mailer.rb,
app/helpers/maktoub/application_helper.rb,
lib/generators/maktoub/config_generator.rb,
app/controllers/maktoub/archives_controller.rb,
app/controllers/maktoub/application_controller.rb,
app/controllers/maktoub/subscribers_controller.rb
Defined Under Namespace
Modules: ApplicationHelper, ArchivesHelper, Generators Classes: ApplicationController, ArchivesController, Engine, NewsletterMailer, SubscribersController
Constant Summary collapse
- VERSION =
"0.5.3"
Class Attribute Summary collapse
-
.app_name ⇒ Object
Returns the value of attribute app_name.
- .email_field ⇒ Object
-
.facebook_url ⇒ Object
Returns the value of attribute facebook_url.
-
.from ⇒ Object
Returns the value of attribute from.
-
.google_plus_url ⇒ Object
Returns the value of attribute google_plus_url.
-
.home_domain ⇒ Object
Returns the value of attribute home_domain.
-
.linkedin_url ⇒ Object
Returns the value of attribute linkedin_url.
-
.logo ⇒ Object
Returns the value of attribute logo.
- .name_field ⇒ Object
-
.subscription_preferences_url ⇒ Object
Returns the value of attribute subscription_preferences_url.
-
.twitter_url ⇒ Object
Returns the value of attribute twitter_url.
-
.unsubscribe_method ⇒ Object
Returns the value of attribute unsubscribe_method.
Class Method Summary collapse
- .home_url ⇒ Object
- .subscribers ⇒ Object
- .subscribers_extractor(&block) ⇒ Object
- .unsubscribe(email) ⇒ Object
Class Attribute Details
.app_name ⇒ Object
Returns the value of attribute app_name.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def app_name @app_name end |
.email_field ⇒ Object
18 19 20 |
# File 'lib/maktoub.rb', line 18 def email_field @email_field || :email end |
.facebook_url ⇒ Object
Returns the value of attribute facebook_url.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def facebook_url @facebook_url end |
.from ⇒ Object
Returns the value of attribute from.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def from @from end |
.google_plus_url ⇒ Object
Returns the value of attribute google_plus_url.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def google_plus_url @google_plus_url end |
.home_domain ⇒ Object
Returns the value of attribute home_domain.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def home_domain @home_domain end |
.linkedin_url ⇒ Object
Returns the value of attribute linkedin_url.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def linkedin_url @linkedin_url end |
.logo ⇒ Object
Returns the value of attribute logo.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def logo @logo end |
.name_field ⇒ Object
22 23 24 |
# File 'lib/maktoub.rb', line 22 def name_field @name_field || :name end |
.subscription_preferences_url ⇒ Object
Returns the value of attribute subscription_preferences_url.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def subscription_preferences_url @subscription_preferences_url end |
.twitter_url ⇒ Object
Returns the value of attribute twitter_url.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def twitter_url @twitter_url end |
.unsubscribe_method ⇒ Object
Returns the value of attribute unsubscribe_method.
5 6 7 |
# File 'lib/maktoub.rb', line 5 def unsubscribe_method @unsubscribe_method end |
Class Method Details
.home_url ⇒ Object
48 49 50 |
# File 'lib/maktoub.rb', line 48 def home_url "http://" + home_domain end |
.subscribers ⇒ Object
26 27 28 |
# File 'lib/maktoub.rb', line 26 def subscribers @subscribers.call end |
.subscribers_extractor(&block) ⇒ Object
30 31 32 |
# File 'lib/maktoub.rb', line 30 def subscribers_extractor (&block) @subscribers = Proc.new &block end |
.unsubscribe(email) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/maktoub.rb', line 34 def unsubscribe(email) if Maktoub.subscribers.class.parents.include?(ActiveRecord) #check if ActiveRecord relation subscriber = subscribers.find_by(email_field => email) subscriber.send(unsubscribe_method) if subscriber.present? else puts 'WARNING!!! Use ActiveRecord query methods to find subscribers. Falling back to iterating through subscribers array (slow!).' subscribers.select do |s| s.send(email_field) == email end.each do |s| s.send(unsubscribe_method) if unsubscribe_method end end end |