Module: Card::Action::Differ
- Included in:
- Card::Action
- Defined in:
- 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.
-
#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
# test whether content was visibly removed # @return [true/false] def red? content_diff_object.red? end.
- #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 'lib/card/action/differ.rb', line 21 def cardtype_diff opts={} return unless card && 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 '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 |
#new_content? ⇒ true/false
does action change card’s content?
44 45 46 |
# File '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 '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 'lib/card/action/differ.rb', line 29 def new_type? !value(:type_id).nil? end |
#raw_view(content = nil) ⇒ Object
# test whether content was visibly removed # @return [true/false] def red?
content_diff_object.red?
end
# test whether content was visibly added # @return [true/false] def green?
content_diff_object.green?
end
60 61 62 63 64 65 66 |
# File '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 |
#summary_diff_omits_content? ⇒ Boolean
68 69 70 |
# File 'lib/card/action/differ.rb', line 68 def summary_diff_omits_content? content_diff_object.summary_omits_content? end |