Module: Calagator::DecodeHtmlEntitiesHack

Included in:
Event, Source, Venue
Defined in:
lib/calagator/decode_html_entities_hack.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



18
19
20
# File 'lib/calagator/decode_html_entities_hack.rb', line 18

def self.included(base)
  base.set_callback(:validate, :before, :decode_html_entities)
end

Instance Method Details

#decode_html_entitiesObject



22
23
24
25
26
27
28
29
# File 'lib/calagator/decode_html_entities_hack.rb', line 22

def decode_html_entities
  attributes.each do |field, value|
    decoded_content = HTMLEntities.new.decode(value)
    if decoded_content.present? && decoded_content != value
      send("#{field}=", decoded_content)
    end
  end
end