Module: Card::Action::Differ
- Included in:
- Card::Action
- Defined in:
- mod/history/lib/card/action/differ.rb
Overview
a collection of methods for comparing actions
Instance Method Summary collapse
-
#cardtype_diff(opts = {}) ⇒ rendered diff
compare action's cardtype value with previous cardtype value.
-
#content_diff(diff_type = :expanded, opts = nil) ⇒ rendered diff
compare action's content value with previous content value.
-
#green? ⇒ true/false
test whether content was visibly added.
-
#name_diff(opts = {}) ⇒ rendered diff
compare action's name value with previous name value.
-
#new_content? ⇒ true/false
does action change card's content?.
-
#new_name? ⇒ true/false
does action change card's name?.
-
#new_type? ⇒ true/false
does action change card's type?.
- #raw_view(content = nil) ⇒ Object
-
#red? ⇒ true/false
test whether content was visibly removed.
- #summary_diff_omits_content? ⇒ Boolean
Instance Method Details
#cardtype_diff(opts = {}) ⇒ rendered diff
compare action's cardtype value with previous cardtype value
21 22 23 24 25 |
# File 'mod/history/lib/card/action/differ.rb', line 21 def cardtype_diff opts={} return unless new_type? diff_object(:cardtype, opts).complete end |
#content_diff(diff_type = :expanded, opts = nil) ⇒ rendered diff
compare action's content value with previous content value
35 36 37 38 39 40 |
# File 'mod/history/lib/card/action/differ.rb', line 35 def content_diff diff_type=:expanded, opts=nil return unless new_content? dobj = content_diff_object(opts) diff_type == :summary ? dobj.summary : dobj.complete end |
#green? ⇒ true/false
test whether content was visibly added
56 57 58 |
# File 'mod/history/lib/card/action/differ.rb', line 56 def green? content_diff_object.green? end |
#name_diff(opts = {}) ⇒ rendered diff
compare action's name value with previous name value
7 8 9 10 11 |
# File 'mod/history/lib/card/action/differ.rb', line 7 def name_diff opts={} return unless new_name? diff_object(:name, opts).complete end |
#new_content? ⇒ true/false
does action change card's content?
44 45 46 |
# File 'mod/history/lib/card/action/differ.rb', line 44 def new_content? !value(:db_content).nil? end |
#new_name? ⇒ true/false
does action change card's name?
15 16 17 |
# File 'mod/history/lib/card/action/differ.rb', line 15 def new_name? !value(:name).nil? end |
#new_type? ⇒ true/false
does action change card's type?
29 30 31 |
# File 'mod/history/lib/card/action/differ.rb', line 29 def new_type? !value(:type_id).nil? end |
#raw_view(content = nil) ⇒ Object
60 61 62 63 64 65 66 |
# File 'mod/history/lib/card/action/differ.rb', line 60 def raw_view content=nil original_content = card.db_content card.db_content = content || value(:db_content) card.format.render_raw ensure card.db_content = original_content end |
#red? ⇒ true/false
test whether content was visibly removed
50 51 52 |
# File 'mod/history/lib/card/action/differ.rb', line 50 def red? content_diff_object.red? end |
#summary_diff_omits_content? ⇒ Boolean
68 69 70 |
# File 'mod/history/lib/card/action/differ.rb', line 68 def summary_diff_omits_content? content_diff_object.summary_omits_content? end |