Module: EffectivePolls

Defined in:
lib/effective_polls.rb,
lib/effective_polls/engine.rb,
lib/effective_polls/version.rb,
lib/generators/effective_polls/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'0.1.2'

Class Method Summary collapse

Class Method Details

.authorize!(controller, action, resource) ⇒ Object



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

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

.authorized?(controller, action, resource) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/effective_polls.rb', line 29

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

.mailer_classObject



46
47
48
49
50
51
52
53
# File 'lib/effective_polls.rb', line 46

def self.mailer_class
  if use_effective_email_templates
    require 'effective_email_templates'
    Effective::EmailTemplatesMailer
  else
    ActionMailer::Base
  end
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



25
26
27
# File 'lib/effective_polls.rb', line 25

def self.setup
  yield self
end