Sha256: c1c4825f3a23104f049b6b908d26114c4f5ed909ba9e2e48aa4cb0d89b457aec
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
require 'rails/mark_requirements/version' module Rails module MarkRequirements # Allow the developer to be lazy and auto-extend the class methods, which # is required for the instance method to work anyway def self.included(klass) # :nodoc: klass.extend ClassMethods end module ClassMethods # :call-seq: # Klass.mark_required? :attribute # # does field_for(object.attribute) require 'a presence' def mark_required?(attribute) validation_classes = self.validators_on(attribute).map(&:class) ret = false ret = true if validation_classes.include?(ActiveModel::Validations::PresenceValidator) ret end end # /class_methods # :call-seq: # mark_required? :attribute # # does field_for(object.attribute) require 'a presence' def mark_required?(attribute) self.class.mark_required?(attribute) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-mark_requirements-0.0.1 | lib/rails/mark_requirements.rb |