Sha256: 1a99f977e5b4a478e5fd546507cddede3c03b72a259c499678f56749e221c880
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
module Discerner module Methods module Models module ParameterType def self.included(base) base.send :include, SoftDelete # Associations base.send :has_many, :parameters, :inverse_of => :parameter_type base.send :has_and_belongs_to_many, :operators, :join_table => :discerner_operators_parameter_types # Validations base.send :validates, :name, :presence => true, :uniqueness => {:message => "for parameter type has already been taken"} base.send :validate, :name_supported? # Whitelisting attributes base.send :attr_accessible, :deleted_at, :name end # Instance Methods def initialize(*args) super(*args) end def name_supported? return if self.name.blank? supported_types = ['numeric', 'date', 'list', 'combobox', 'text', 'string', 'search'] errors.add(:base,"Parameter type '#{self.name}' is not supported, please use one of the following types: #{supported_types.join(', ')}") unless supported_types.include?(self.name) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems