Class: Glib::ApplicationPolicy

Inherits:
Object
  • Object
show all
Defined in:
app/policies/glib/application_policy.rb

Defined Under Namespace

Classes: Scope

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



100
101
102
103
104
105
106
# File 'app/policies/glib/application_policy.rb', line 100

def method_missing(name, *args, &block)
  if name.to_s.end_with?('?') && catch_all
    call_catch_all
  else
    super
  end
end

Class Attribute Details

.catch_allObject (readonly)

Returns the value of attribute catch_all.



20
21
22
# File 'app/policies/glib/application_policy.rb', line 20

def catch_all
  @catch_all
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



5
6
7
# File 'app/policies/glib/application_policy.rb', line 5

def controller
  @controller
end

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'app/policies/glib/application_policy.rb', line 5

def params
  @params
end

#policy_nameObject (readonly)

Returns the value of attribute policy_name.



5
6
7
# File 'app/policies/glib/application_policy.rb', line 5

def policy_name
  @policy_name
end

#recordObject (readonly)

Returns the value of attribute record.



5
6
7
# File 'app/policies/glib/application_policy.rb', line 5

def record
  @record
end

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'app/policies/glib/application_policy.rb', line 5

def request
  @request
end

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'app/policies/glib/application_policy.rb', line 5

def user
  @user
end

Class Method Details

.args_builderObject



117
118
119
# File 'app/policies/glib/application_policy.rb', line 117

def self.args_builder
  Proc.new { |controller| [] }
end

Instance Method Details

#scopeObject



109
110
111
112
113
114
# File 'app/policies/glib/application_policy.rb', line 109

def scope
  policy_scope_class = Pundit::PolicyFinder.new(@policy_name).scope
  return unless policy_scope_class

  controller.policy_scope(record.class, policy_scope_class: policy_scope_class)
end