Module: EffectivePosts
- Defined in:
- lib/effective_posts.rb,
lib/effective_posts/engine.rb,
lib/effective_posts/version.rb,
lib/generators/effective_posts/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Engine
Constant Summary
collapse
- VERSION =
'1.0.2'.freeze
Class Method Summary
collapse
Class Method Details
.authorize!(controller, action, resource) ⇒ Object
52
53
54
|
# File 'lib/effective_posts.rb', line 52
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
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/effective_posts.rb', line 39
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
|
.permitted_params ⇒ Object
56
57
58
59
60
61
|
# File 'lib/effective_posts.rb', line 56
def self.permitted_params
@@permitted_params ||= [
:title, :description, :draft, :category, :published_at, :body, :tags, :extra,
:start_at, :end_at, :location, :website_name, :website_href, roles: []
].compact
end
|
.setup {|_self| ... } ⇒ Object
35
36
37
|
# File 'lib/effective_posts.rb', line 35
def self.setup
yield self
end
|