Sha256: 3cfdaeb3dea201c7e0f11786f258ee4cdac26552eb6d73f6ca957de6e72f5712

Contents?: true

Size: 784 Bytes

Versions: 7

Compression:

Stored size: 784 Bytes

Contents

module ActiveModel
  module Validations

    module ClassMethods

      def validation_group(group, options={}, &block)
        raise "The validation_group method requires a block" unless block_given?

        unless include?(GroupedValidations)
          include GroupedValidations
        end

        self.validation_groups += [ group ]

        _define_group_validation_callbacks(group)

        options[:name] = group

        if block.arity == 1
          @_current_validation_group = options.merge(:with_options => true)
          with_options(options.except(:name)) do |config|
            yield config
          end
        else
          @_current_validation_group = options
          yield
        end
        @_current_validation_group = nil
      end

    end

  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
grouped_validations-0.3.2 lib/grouped_validations/active_model.rb
grouped_validations-0.3.1 lib/grouped_validations/active_model.rb
monkey_forms-0.0.20 lib/monkey_forms/vendor/grouped_validations/lib/grouped_validations/active_model.rb
monkey_forms-0.0.19 lib/monkey_forms/vendor/grouped_validations/lib/grouped_validations/active_model.rb
monkey_forms-0.0.18 lib/monkey_forms/vendor/grouped_validations/lib/grouped_validations/active_model.rb
monkey_forms-0.0.17 lib/monkey_forms/vendor/grouped_validations/lib/grouped_validations/active_model.rb
grouped_validations-0.3.0 lib/grouped_validations/active_model.rb