Sha256: 74f8eb99da05eecf2f135f7d2ce0a02c053254d11c083d3680d87dc9963592e4
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require 'active_support/concern' module EacRailsUtils module Models module AttributeRequired extend ::ActiveSupport::Concern class << self def required?(model_class_or_record, attribute) model = model_class_or_record_to_model(model_class_or_record) record = model.new record.validate record.errors.key?(attribute.to_sym) end private def model_class_or_record_to_model(model_class_or_record) model_class_or_record.is_a?(::Class) ? model_class_or_record : model_class_or_record.class end end included do extend ClassMethods include InstanceMethods end module ClassMethods def column_required?(column) ::EacRailsUtils::Models::AttributeRequired.required?(self, column) end end module InstanceMethods def attribute_required?(column) self.class.column_required?(column) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems