README.md in csv_row_model-0.2.1 vs README.md in csv_row_model-0.3.0

- old
+ new

@@ -287,11 +287,11 @@ presenter do # define your presenter here # this is shorthand for the psuedo_code: # def project - # return if row_model.id.invalid? || row_model.name.invalid? + # return if row_model.id.blank? || row_model.name.blank? # # # turn off memoziation with `memoize: false` option # @project ||= __the_code_inside_the_block__ # end # @@ -326,13 +326,13 @@ Also, the `attribute` defines a dynamic `#project` method that: 1. Memoizes by default, turn off with `memoize: false` option 2. All errors of `row_model` are propagated to the presenter when calling `presenter.valid?` -3. Handles dependencies. When any of the dependencies are `invalid?`: - - The attribute block is not called and the attribute returns `nil`. - - `presenter.errors` for dependencies are cleaned. For the example above, if `row_model.id/name` are `invalid?`, then +3. Handles dependencies: + - When any of the dependencies are `blank?`, the attribute block is not called and the attribute returns `nil`. + - When any of the dependencies are `invalid?`, `presenter.errors` for dependencies are cleaned. For the example above, if `row_model.id/name` are `invalid?`, then the `:project` key is removed from the errors, so: `presenter.errors.keys # => [:id, :name]` ## Import Validations Use [`ActiveModel::Validations`](http://api.rubyonrails.org/classes/ActiveModel/Validations.html) the `RowModel`'s [Layers](#layers). @@ -438,11 +438,12 @@ class DynamicColumnModel include CsvRowModel::Model column :first_name column :last_name - dynamic_column :skills + # header is optional, below is the default_implementation + dynamic_column :skills, header: ->(skill_name) { skill_name } end ``` represents this table: @@ -462,16 +463,9 @@ include CsvRowModel::Export def skill(skill_name) # below is an override, this is the default implementation: skill_name # => "skill1", then "skill2" source_model.skills.include?(skill_name) ? "Yes" : "No" - end - - class << self - # this is an override with the default implementation - def skill_header(skill_name) - skill_name - end end end # the `skills` context is mapped to generate an array export_file = CsvRowModel::Export::File.new(DynamicColumnExportModel, { skills: Skill.all }) \ No newline at end of file