<commit_before>require 'test_helper'

class SkipIfTest < BaseTest

  class AlbumForm < Reform::Form
    property :title

    property :hit, skip_if: lambda { |fragment, *| fragment["title"].blank? } do
      property :title
      validates :title, presence: true
    end

    collection :songs, skip_if: lambda { |fragment, *| fragment["title"].nil? },
      populate_if_empty: BaseTest::Song do
      property :title
    end
  end


  let (:hit) { Song.new }
  let (:album) { Album.new(nil, hit, [], nil) }
<commit_msg>:skip_if can also be an instance method symbol.<commit_after>require 'test_helper'

class SkipIfTest < BaseTest

  class AlbumForm < Reform::Form
    property :title

    property :hit, skip_if: lambda { |fragment, *| fragment["title"].blank? } do
      property :title
      validates :title, presence: true
    end

    collection :songs, skip_if: :skip_song?, populate_if_empty: BaseTest::Song do
      property :title
    end

    def skip_song?(fragment, options)
      fragment["title"].nil?
    end
  end


  let (:hit) { Song.new }
  let (:album) { Album.new(nil, hit, [], nil) }

{'fraction_non_alphanumeric': 0.12454873646209386, 'fraction_numerical': 0.0, 'mean_word_length': 3.298449612403101, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2841708', 'n_tokens_mistral': 364, 'n_tokens_neox': 342, 'n_words': 100}