Class: LaunchControl::MandrillContract
- Inherits:
-
Object
- Object
- LaunchControl::MandrillContract
- Defined in:
- lib/launch_control/mandrill_contract.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
- #default_email_contract ⇒ Object
- #deliver(options) ⇒ Object
-
#merged_contract ⇒ Object
Override these to control how your validations and merge variables get integrated with Launch Control defaults.
- #merged_options(options) ⇒ Object
-
#template ⇒ Object
Override this with your template id from Mandrill.
- #valid?(options) ⇒ Boolean
-
#validations ⇒ Object
Override this with any custom validations you wish to perform on your mail object before delivering.
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/launch_control/mandrill_contract.rb', line 7 def errors @errors end |
Instance Method Details
#default_email_contract ⇒ Object
51 52 53 54 55 56 |
# File 'lib/launch_control/mandrill_contract.rb', line 51 def default_email_contract { to: lambda { |to| [Array,String,Hash].include?(to.class) }, subject: 'string' } end |
#deliver(options) ⇒ Object
45 46 47 48 49 |
# File 'lib/launch_control/mandrill_contract.rb', line 45 def deliver() = () launch = LaunchControl::Mailer.new(template, ) valid?() && launch.valid? && launch.deliver end |
#merged_contract ⇒ Object
Override these to control how your validations and merge variables get integrated with Launch Control defaults. For example:
def ()
.merge(to_json)
end
This allows you to wrap any custom merge vars into a to_json method for a cleaner interaction.
36 37 38 |
# File 'lib/launch_control/mandrill_contract.rb', line 36 def merged_contract default_email_contract.merge!(validations) end |
#merged_options(options) ⇒ Object
40 41 42 |
# File 'lib/launch_control/mandrill_contract.rb', line 40 def () end |
#template ⇒ Object
Override this with your template id from Mandrill.
20 21 22 |
# File 'lib/launch_control/mandrill_contract.rb', line 20 def template raise 'You must define a Mandrill template to use' end |
#valid?(options) ⇒ Boolean
58 59 60 61 62 63 64 65 66 |
# File 'lib/launch_control/mandrill_contract.rb', line 58 def valid?() validator = HashValidator.validate(, merged_contract) if validator.valid? true else @errors = validator.errors false end end |
#validations ⇒ Object
Override this with any custom validations you wish to perform on your mail object before delivering.
13 14 15 |
# File 'lib/launch_control/mandrill_contract.rb', line 13 def validations {} end |