Module: EffectiveMergery
- Defined in:
- lib/effective_mergery.rb,
lib/effective_mergery/engine.rb,
lib/effective_mergery/version.rb,
lib/generators/effective_mergery/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Engine
Constant Summary
collapse
- VERSION =
'0.1.4'.freeze
Class Method Summary
collapse
Class Method Details
.authorized?(controller, action, resource) ⇒ Boolean
19
20
21
22
23
24
|
# File 'lib/effective_mergery.rb', line 19
def self.authorized?(controller, action, resource)
if authorization_method.respond_to?(:call) || authorization_method.kind_of?(Symbol)
raise Effective::AccessDenied.new() unless (controller || self).instance_exec(controller, action, resource, &authorization_method)
end
true
end
|
.mergables ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/effective_mergery.rb', line 26
def self.mergables
@mergables ||= (
Rails.application.eager_load! unless Rails.configuration.cache_classes
blacklist = ['Delayed::', 'Effective::', 'ActiveRecord::', 'ApplicationRecord']
ActiveRecord::Base.descendants.map { |obj| obj.name }.tap do |names|
names.reject! { |name| blacklist.any? { |b| name.start_with?(b) } }
if (onlies = Array(only)).present?
names.select! { |name| onlies.include?(name) }
elsif (excepts = Array(except)).present?
names.reject! { |name| excepts.include?(name) }
end
end.sort
)
end
|
.setup {|_self| ... } ⇒ Object
15
16
17
|
# File 'lib/effective_mergery.rb', line 15
def self.setup
yield self
end
|