Sha256: 49eb26e50ee70c5b79366adb04bca75627b98f52f04318c5bdf0b216c751c012

Contents?: true

Size: 864 Bytes

Versions: 24

Compression:

Stored size: 864 Bytes

Contents

module ActiveScaffold
  module ValidationReflectionBridge
    def self.included(base)
      base.class_eval { alias_method_chain :initialize, :validation_reflection }
    end

    def initialize_with_validation_reflection(name, active_record_class)
      initialize_without_validation_reflection(name, active_record_class)
      column_names = [name]
      column_names << @association.foreign_key if @association
      self.required = column_names.any? do |column_name|
        active_record_class.reflect_on_validations_for(column_name.to_sym).any? do |val|
          val.macro == :validates_presence_of or (val.macro == :validates_inclusion_of and not val.options[:allow_nil] and not val.options[:allow_blank])
        end
      end
    end
  end
end
ActiveScaffold::DataStructures::Column.class_eval do
  include ActiveScaffold::ValidationReflectionBridge
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
active_scaffold_vho-4.0.0 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.14 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.13 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.12 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.11 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.10 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.9 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.8 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.7 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.6 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.5 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.4 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.3 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.2 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.1 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.2.0 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.1.8 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.1.6 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.1.5 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb
active_scaffold_vho-3.1.4 lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb