Module: Godmin::Helpers::Application

Defined in:
lib/godmin/helpers/application.rb

Instance Method Summary collapse

Instance Method Details

#partial_override(partial, locals = {}) ⇒ Object

Renders the provided partial with locals if it exists, otherwise yields the given block.



6
7
8
9
10
11
12
# File 'lib/godmin/helpers/application.rb', line 6

def partial_override(partial, locals = {})
  if lookup_context.exists?(partial, nil, true)
    render partial: partial, locals: locals
  else
    yield
  end
end

#policy(resource) ⇒ Object

Wraps the policy helper so that it is always accessible, even when authorization is not enabled. When that is the case, it returns a policy that always returns true.



17
18
19
20
21
22
23
# File 'lib/godmin/helpers/application.rb', line 17

def policy(resource)
  if authorization_enabled?
    super(resource)
  else
    Authorization::Policy.new(nil, nil, default: true)
  end
end