Skip to content

:carry_forward option #109

Description

@s12chung

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions