Exception: Authz::Scopables::Base::AmbiguousAssociationName

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

Overview

Error that will be raised if the model being scoped has ambiguous association names for the included scopable (e.g. has both :city and :cities associations and ScopableByCity is Being included)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AmbiguousAssociationName

Returns a new instance of AmbiguousAssociationName.



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/authz/scopables/base.rb', line 76

def initialize(options = {})
  @scoped_class  = options.fetch(:scoped_class)
  @scopable = options.fetch :scopable
  @association_names = options.fetch :association_names
  message = "#{scoped_class} has ambiguous association names " \
             "#{association_names} for #{scopable}. " \
             'Use the ' \
             "set_scopable_by_#{scopable.scoping_class_name.underscore}_association_name " \
             'method to define it manually.'
  super(message)
end

Instance Attribute Details

#association_namesObject (readonly)



74
75
76
# File 'lib/authz/scopables/base.rb', line 74

def association_names
  @association_names
end

#scopableObject (readonly)



74
75
76
# File 'lib/authz/scopables/base.rb', line 74

def scopable
  @scopable
end

#scoped_classObject (readonly)



74
75
76
# File 'lib/authz/scopables/base.rb', line 74

def scoped_class
  @scoped_class
end