Class: CanCanExplainer::Explanation
- Inherits:
-
Object
- Object
- CanCanExplainer::Explanation
- Defined in:
- lib/cancan_explainer/explanation.rb
Instance Method Summary collapse
- #add_condition_match(source_location, action, subject, extra_args) ⇒ Object
-
#initialize ⇒ Explanation
constructor
A new instance of Explanation.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Explanation
Returns a new instance of Explanation.
3 4 5 |
# File 'lib/cancan_explainer/explanation.rb', line 3 def initialize @conditions_matched = [] end |
Instance Method Details
#add_condition_match(source_location, action, subject, extra_args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/cancan_explainer/explanation.rb', line 7 def add_condition_match(source_location, action, subject, extra_args) @conditions_matched.push( { source_location: source_location, action: action, subject: subject, extra_args: extra_args } ) end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cancan_explainer/explanation.rb', line 18 def to_s @conditions_matched.map { |e| format( "%s %s %s %s", e[:action], e[:subject], e[:extra_args], e[:source_location] ) }.join("\n") end |