Class: ActiveEntry::PolicyFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_entry/policy_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name) ⇒ PolicyFinder

Returns a new instance of PolicyFinder.



5
6
7
# File 'lib/active_entry/policy_finder.rb', line 5

def initialize class_name
  @class_name = class_name
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



3
4
5
# File 'lib/active_entry/policy_finder.rb', line 3

def class_name
  @class_name
end

Class Method Details

.policy_for(class_name) ⇒ Object



10
11
12
# File 'lib/active_entry/policy_finder.rb', line 10

def policy_for class_name
  new(class_name).policy
end

Instance Method Details

#policyObject



15
16
17
# File 'lib/active_entry/policy_finder.rb', line 15

def policy
  policy_class_name.safe_constantize or raise NotDefinedError.new(policy_class_name, @class_name)
end