Module: Pundit::Before
- Defined in:
- lib/pundit/before.rb,
lib/pundit/before/version.rb
Defined Under Namespace
Modules: ClassMethods, VERSION
Classes: CallbackFilter
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.gem_version ⇒ Object
18
19
20
|
# File 'lib/pundit/before/version.rb', line 18
def self.gem_version
Gem::Version.new VERSION::STRING
end
|
.included(base) ⇒ Object
rubocop:disable Metrics/MethodLength
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/pundit/before.rb', line 13
def self.included(base)
base.extend ClassMethods
base.include ActiveSupport::Callbacks
base.class_eval do
define_callbacks :_pundit_before, skip_after_callbacks_if_terminated: true
def self.method_added(method_name)
super
return unless method_name.to_s =~ /.*\?$/ && public_method_defined?(method_name)
return if @_pundit_before_running
@_pundit_before_running = true
old_method = instance_method(method_name)
redefine_method(method_name) do
@_pundit_before_result = nil
@_pundit_before_method = method_name
run_callbacks :_pundit_before
@_pundit_before_result.nil? ? old_method.bind(self).call : @_pundit_before_result
end
@_pundit_before_running = false
end
end
end
|
.version ⇒ Object
14
15
16
|
# File 'lib/pundit/before/version.rb', line 14
def self.version
VERSION::STRING
end
|
Instance Method Details
#allow! ⇒ Object
88
89
90
91
|
# File 'lib/pundit/before.rb', line 88
def allow!
@_pundit_before_result = true
throw :abort
end
|
#deny! ⇒ Object
93
94
95
96
|
# File 'lib/pundit/before.rb', line 93
def deny!
@_pundit_before_result = false
throw :abort
end
|