Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:carry_forward option #109

Open
s12chung opened this issue Oct 5, 2016 · 0 comments
Open

:carry_forward option #109

s12chung opened this issue Oct 5, 2016 · 0 comments

Comments

@s12chung
Copy link
Contributor

s12chung commented Oct 5, 2016

we have this documentation internally in our README.

Empty Cells Implying Previous Cell

Suppose you have a table like thus:

id name
1 a
* b

where * is an empty cell, but it really implies “1”, the previous id.

You can memoize and point to the previous cell:

class ProjectImportRow
  def id
    # `#previous` is from `csv_row_model`
    # memoize because `previous.previous` is always `nil`, otherwise `csv_row_model` creates a linked list
    @id ||= original_attribute(:id) || previous.try(:id)
  end
end

want to implement this with a :carry_forward, :or_previous, :take_previous option---I'm open to other words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant