Sha256: b70b53b1da14718bcaab8ff3171617d14b18a462c44733b9ef4b05ddd4ac134d
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'maily/engine' require 'maily/version' require 'maily/mailer' require 'maily/email' module Maily class << self attr_accessor :enabled, :allow_edition, :allow_delivery, :available_locales, :base_controller def init! self.enabled = Rails.env.production? ? false : true self.allow_edition = Rails.env.production? ? false : true self.allow_delivery = Rails.env.production? ? false : true self.available_locales = I18n.available_locales self.base_controller = 'ActionController::Base' end def load_emails_and_hooks # Load emails from file system Dir[Rails.root + 'app/mailers/*.rb'].each do |mailer| klass = File.basename(mailer, '.rb') methods = klass.camelize.constantize.send(:instance_methods, false) Maily::Mailer.new(klass, methods) end # Load hooks hooks_file_path = "#{Rails.root}/lib/maily_hooks.rb" require hooks_file_path if File.exists?(hooks_file_path) end def hooks_for(mailer_name) mailer = Maily::Mailer.find(mailer_name.underscore) yield(mailer) if block_given? end def setup init! yield(self) if block_given? end def allowed_action?(action) case action.to_sym when :edit allow_edition when :update allow_edition && !Rails.env.production? when :deliver allow_delivery end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
maily-0.3.5 | lib/maily.rb |
maily-0.3.4 | lib/maily.rb |