Sha256: 3f926150d1b05d4571902a1524b6a170432168ba75f0dfe72931ba97cd95a441

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require "liquid"
require "effective_email_templates/engine"
require "effective_email_templates/version"

module EffectiveEmailTemplates

  mattr_accessor :email_templates_table_name
  mattr_accessor :authorization_method
  mattr_accessor :select_content_type
  mattr_accessor :layout

  def self.setup
    yield self
  end

  def self.authorized?(controller, action, resource)
    @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact

    return !!authorization_method unless authorization_method.respond_to?(:call)
    controller = controller.controller if controller.respond_to?(:controller)

    begin
      !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
    rescue *@_exceptions
      false
    end
  end

  def self.authorize!(controller, action, resource)
    raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
  end

  def self.permitted_params
    [:from, :bcc, :cc, :subject, :body, :content_type]
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
effective_email_templates-1.0.13 lib/effective_email_templates.rb
effective_email_templates-1.0.12 lib/effective_email_templates.rb
effective_email_templates-1.0.11 lib/effective_email_templates.rb
effective_email_templates-1.0.10 lib/effective_email_templates.rb
effective_email_templates-1.0.9 lib/effective_email_templates.rb