Class: Decidim::Plans::DiffRenderer::Base
- Inherits:
-
Object
- Object
- Decidim::Plans::DiffRenderer::Base
- Includes:
- ApplicationHelper
- Defined in:
- app/services/decidim/plans/diff_renderer/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#diff ⇒ Object
Renders the diff of the given changeset.
-
#initialize(version, locale) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(version, locale) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'app/services/decidim/plans/diff_renderer/base.rb', line 9 def initialize(version, locale) @version = version @display_locale = locale end |
Instance Method Details
#diff ⇒ Object
Renders the diff of the given changeset. Doesn’t take into account translatable fields.
Returns a Hash, where keys are the fields that have changed and values are an array, the first element being the previous value and the last being the new one.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/decidim/plans/diff_renderer/base.rb', line 20 def diff version.changeset.inject({}) do |diff, (attribute, values)| attribute = attribute.to_sym type = attribute_types[attribute] if type.blank? diff elsif [:i18n, :i18n_html].include?(type) parse_i18n_changeset(attribute, values, type, diff) else parse_changeset(attribute, values, type, diff) end end end |