module Discerner::Methods::Models::ParameterType

Public Class Methods

included(base) click to toggle source
# File lib/discerner/methods/models/parameter_type.rb, line 5
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?
end
new(*args) click to toggle source

Instance Methods

Calls superclass method
# File lib/discerner/methods/models/parameter_type.rb, line 18
def initialize(*args)
  super(*args)
end

Public Instance Methods

name_supported?() click to toggle source
# File lib/discerner/methods/models/parameter_type.rb, line 22
def name_supported?
  return if self.name.blank?
  supported_types = ['numeric', 'date', 'list', 'combobox', 'text', 'string', 'search', 'exclusive_list']
  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