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

Class Method Summary collapse

Class Attribute Details

.app_nameObject

Returns the value of attribute app_name.



5
6
7
# File 'lib/maktoub.rb', line 5

def app_name
  @app_name
end

.email_fieldObject



18
19
20
# File 'lib/maktoub.rb', line 18

def email_field
  @email_field || :email
end

.facebook_urlObject

Returns the value of attribute facebook_url.



5
6
7
# File 'lib/maktoub.rb', line 5

def facebook_url
  @facebook_url
end

.fromObject

Returns the value of attribute from.



5
6
7
# File 'lib/maktoub.rb', line 5

def from
  @from
end

.google_plus_urlObject

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_domainObject

Returns the value of attribute home_domain.



5
6
7
# File 'lib/maktoub.rb', line 5

def home_domain
  @home_domain
end

.linkedin_urlObject

Returns the value of attribute linkedin_url.



5
6
7
# File 'lib/maktoub.rb', line 5

def linkedin_url
  @linkedin_url
end

.logoObject

Returns the value of attribute logo.



5
6
7
# File 'lib/maktoub.rb', line 5

def 
  @logo
end

.name_fieldObject



22
23
24
# File 'lib/maktoub.rb', line 22

def name_field
  @name_field || :name
end

.subscription_preferences_urlObject

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_urlObject

Returns the value of attribute twitter_url.



5
6
7
# File 'lib/maktoub.rb', line 5

def twitter_url
  @twitter_url
end

.unsubscribe_methodObject

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_urlObject



48
49
50
# File 'lib/maktoub.rb', line 48

def home_url
  "http://" + home_domain
end

.subscribersObject



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