Class: Mimi::DB::Model
Class Method Summary collapse
-
.before_validation(method = nil, &block) ⇒ Object
Defines a hook the ActiveRecord way.
Instance Method Summary collapse
- #before_validation ⇒ Object
-
#default_validation_helpers_options(type) ⇒ Object
Keeps messages as error types, not human readable strings.
Methods included from Dictate
diff_schema, included, schema_definitions, start, update_schema!
Class Method Details
.before_validation(method = nil, &block) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/mimi/db/model.rb', line 38 def self.before_validation(method = nil, &block) if method && block raise ArgumentError, '.before_validation() cannot accept both method and a block' end block = -> { send(method) } if method register_hook(:before_validation, block) end |
Instance Method Details
#before_validation ⇒ Object
21 22 23 24 |
# File 'lib/mimi/db/model.rb', line 21 def before_validation super call_hooks(:before_validation) end |
#default_validation_helpers_options(type) ⇒ Object
Keeps messages as error types, not human readable strings
17 18 19 |
# File 'lib/mimi/db/model.rb', line 17 def (type) { message: type } end |