Sha256: e0ef84313b4844361811c55b1150bec1208f4e8c2d555962cb5fbe46d2560460

Contents?: true

Size: 839 Bytes

Versions: 13

Compression:

Stored size: 839 Bytes

Contents

module Shoulda
  module Matchers
    module ActiveModel
      class AllowValueMatcher
        # @private
        class AttributeSetters
          include Enumerable

          def initialize(allow_value_matcher, values)
            @tuples = values.map do |attribute_name, value|
              AttributeSetterAndValidator.new(
                allow_value_matcher,
                attribute_name,
                value,
              )
            end
          end

          def each(&block)
            tuples.each(&block)
          end

          def first_failing
            tuples.detect(&method(:does_not_match?))
          end

          protected

          attr_reader :tuples

          private

          def does_not_match?(tuple)
            !tuple.attribute_setter.set!
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb