Exception: Authz::Scopables::Base::MisconfiguredAssociation

Inherits:
StandardError
  • Object
show all
Defined in:
lib/authz/scopables/base.rb

Overview

Error that will be raised if the association of a model being scoped does not return the expected type of objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MisconfiguredAssociation

Returns a new instance of MisconfiguredAssociation.



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/authz/scopables/base.rb', line 111

def initialize(options = {})
  @scoped_class  = options.fetch(:scoped_class)
  @scopable = options.fetch :scopable
  @association_method = options.fetch :association_method
  message = "#{scoped_class} has a misconfigured association " \
             "for #{scopable}. " \
             "Make sure that ##{association_method} " \
             'returns either an instance of class' \
             "#{scopable.scoping_class_name} " \
             'or a collection that responds to #pluck(:id).'
  super(message)
end

Instance Attribute Details

#association_methodObject (readonly)



109
110
111
# File 'lib/authz/scopables/base.rb', line 109

def association_method
  @association_method
end

#scopableObject (readonly)



109
110
111
# File 'lib/authz/scopables/base.rb', line 109

def scopable
  @scopable
end

#scoped_classObject (readonly)



109
110
111
# File 'lib/authz/scopables/base.rb', line 109

def scoped_class
  @scoped_class
end