Class: MaquinaNewsletters::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/maquina_newsletters/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



24
25
26
27
28
29
30
31
32
33
# File 'lib/maquina_newsletters/configuration.rb', line 24

def initialize
  @recipient_model = "User"
  @recipient_scope = :active
  @recipient_email_attr = :email_address

  @base_controller_class = "ActionController::Base"
  @http_basic_auth_enabled = false
  @http_basic_auth_user = nil
  @http_basic_auth_password = nil
end

Instance Attribute Details

#base_controller_classObject

Controller integration (mirrors rails/mission_control-jobs).

base_controller_class — the controller the engine’s ApplicationController inherits from, as a String constantized at load time. Defaults to “ActionController::Base” so the engine works standalone. A host app points this at its own authenticated base controller (e.g. “BackstageController”), which is where authentication belongs — NOT in the engine.

http_basic_auth_* — an OPTIONAL fallback for hosts whose base controller does not already authenticate. Off by default; when enabled with a user and password, the engine’s BasicAuthentication concern enforces HTTP Basic Auth. When the host’s base controller handles auth, leave this disabled.



19
20
21
# File 'lib/maquina_newsletters/configuration.rb', line 19

def base_controller_class
  @base_controller_class
end

#http_basic_auth_enabledObject

Controller integration (mirrors rails/mission_control-jobs).

base_controller_class — the controller the engine’s ApplicationController inherits from, as a String constantized at load time. Defaults to “ActionController::Base” so the engine works standalone. A host app points this at its own authenticated base controller (e.g. “BackstageController”), which is where authentication belongs — NOT in the engine.

http_basic_auth_* — an OPTIONAL fallback for hosts whose base controller does not already authenticate. Off by default; when enabled with a user and password, the engine’s BasicAuthentication concern enforces HTTP Basic Auth. When the host’s base controller handles auth, leave this disabled.



19
20
21
# File 'lib/maquina_newsletters/configuration.rb', line 19

def http_basic_auth_enabled
  @http_basic_auth_enabled
end

#http_basic_auth_passwordObject

Controller integration (mirrors rails/mission_control-jobs).

base_controller_class — the controller the engine’s ApplicationController inherits from, as a String constantized at load time. Defaults to “ActionController::Base” so the engine works standalone. A host app points this at its own authenticated base controller (e.g. “BackstageController”), which is where authentication belongs — NOT in the engine.

http_basic_auth_* — an OPTIONAL fallback for hosts whose base controller does not already authenticate. Off by default; when enabled with a user and password, the engine’s BasicAuthentication concern enforces HTTP Basic Auth. When the host’s base controller handles auth, leave this disabled.



19
20
21
# File 'lib/maquina_newsletters/configuration.rb', line 19

def http_basic_auth_password
  @http_basic_auth_password
end

#http_basic_auth_userObject

Controller integration (mirrors rails/mission_control-jobs).

base_controller_class — the controller the engine’s ApplicationController inherits from, as a String constantized at load time. Defaults to “ActionController::Base” so the engine works standalone. A host app points this at its own authenticated base controller (e.g. “BackstageController”), which is where authentication belongs — NOT in the engine.

http_basic_auth_* — an OPTIONAL fallback for hosts whose base controller does not already authenticate. Off by default; when enabled with a user and password, the engine’s BasicAuthentication concern enforces HTTP Basic Auth. When the host’s base controller handles auth, leave this disabled.



19
20
21
# File 'lib/maquina_newsletters/configuration.rb', line 19

def http_basic_auth_user
  @http_basic_auth_user
end

#recipient_email_attrObject

Returns the value of attribute recipient_email_attr.



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

def recipient_email_attr
  @recipient_email_attr
end

#recipient_modelObject

Returns the value of attribute recipient_model.



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

def recipient_model
  @recipient_model
end

#recipient_scopeObject

Returns the value of attribute recipient_scope.



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

def recipient_scope
  @recipient_scope
end

Instance Method Details

#recipient_classObject

Constantizes the recipient_model string. Lazy so engines don’t have to know about the host’s models at load time.



37
38
39
# File 'lib/maquina_newsletters/configuration.rb', line 37

def recipient_class
  recipient_model.constantize
end

#recipient_relationObject

Calls the scope on the recipient class. Returns an ActiveRecord::Relation.



42
43
44
# File 'lib/maquina_newsletters/configuration.rb', line 42

def recipient_relation
  recipient_class.public_send(recipient_scope)
end