Skip to content
Leandro Segovia edited this page Feb 23, 2018 · 1 revision

Right now, the gem has one hook only:

1 - After parse row

You can run custom behavior after parsing a row. For example:

class SuperheroesParser < Parxer::XlsParser
  column(:name, name: "Name")
  column(:real_name, name: "Real Name")

  after_parse_row do
    row.add_attribute(:full_name) # Add attributes dynamically
    row.full_name = "#{row.name} (#{row.real_name})" unless row.errors?
  end
end

As you can see on the previous example, a full_name attribute will be added to the parsed row if this has no errors.

Clone this wiki locally