Module: Validateable

Included in:
DelegateValidation::Validator, Endpoints::Uuids::Search, Request::ChangeDecision
Defined in:
lib/validateable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *_params) ⇒ Object


4
5
6
7
8
# File 'lib/validateable.rb', line 4

def method_missing(symbol, *_params)
  if symbol.to_s =~ /(.*)_before_type_cast$/
    send($1)
  end
end

Class Method Details

.append_features(base) ⇒ Object


10
11
12
13
14
# File 'lib/validateable.rb', line 10

def self.append_features(base)
  super
  base.send(:include, ActiveModel::Validations)
  base.extend ClassMethods
end

Instance Method Details

#validate!Object


16
17
18
# File 'lib/validateable.rb', line 16

def validate!
  raise(ActiveRecord::RecordInvalid, self) unless valid?
end