Sha256: f4120ee9e27d728e73f40f81af749b40434131c2c75b4b4ea95eab20dec43690

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 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 :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

8 entries across 8 versions & 1 rubygems

Version Path
effective_email_templates-1.0.8 lib/effective_email_templates.rb
effective_email_templates-1.0.7 lib/effective_email_templates.rb
effective_email_templates-1.0.6 lib/effective_email_templates.rb
effective_email_templates-1.0.5 lib/effective_email_templates.rb
effective_email_templates-1.0.4 lib/effective_email_templates.rb
effective_email_templates-1.0.3 lib/effective_email_templates.rb
effective_email_templates-1.0.2 lib/effective_email_templates.rb
effective_email_templates-1.0.1 lib/effective_email_templates.rb