Module: Discerner::Methods::Models::ParameterType
- Included in:
- ParameterType
- Defined in:
- lib/discerner/methods/models/parameter_type.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
Instance Methods.
- #name_supported? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# 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 |
Instance Method Details
#initialize(*args) ⇒ Object
Instance Methods
18 19 20 |
# File 'lib/discerner/methods/models/parameter_type.rb', line 18 def initialize(*args) super(*args) end |
#name_supported? ⇒ Boolean
22 23 24 25 26 |
# 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'] 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 |