Class: Dancan::PolicyFinder
- Inherits:
-
Object
- Object
- Dancan::PolicyFinder
- Defined in:
- lib/dancan/policy_finder.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(object) ⇒ PolicyFinder
constructor
A new instance of PolicyFinder.
- #policy ⇒ Object
- #policy! ⇒ Object
Constructor Details
#initialize(object) ⇒ PolicyFinder
Returns a new instance of PolicyFinder.
5 6 7 |
# File 'lib/dancan/policy_finder.rb', line 5 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/dancan/policy_finder.rb', line 3 def object @object end |
Instance Method Details
#policy ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/dancan/policy_finder.rb', line 9 def policy klass = find klass = klass.constantize if klass.is_a?(String) klass rescue NameError nil end |
#policy! ⇒ Object
17 18 19 |
# File 'lib/dancan/policy_finder.rb', line 17 def policy! policy or raise NotDefinedError, "unable to find policy #{find} for #{object}" end |