Module: Themis::AR::BaseExtension

Extended by:
ActiveSupport::Autoload
Defined in:
lib/themis/ar/base_extension.rb

Overview

Extends ActiveRecord::Base to make it support has_validation and use_validation methods. It adds some class attributes to model:

  • themis_validation - name of validation, symbol or nil

  • themis_validation_sets - hash where key is symbol(validation name) and value is ValidationSet.

  • themis_default_validation - name of default validation.

  • themis_default_nested - default value for :nested option

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/themis/ar/base_extension.rb', line 14

def self.included(base)
  base.extend         ClassMethods
  base.send :include, InstanceMethods
  base.send :include, Callbacks

  base.class_eval(<<-eoruby, __FILE__, __LINE__+1)
    attr_reader :themis_validation

    class_attribute :themis_validation_sets
    class_attribute :themis_default_validation
    class_attribute :themis_default_nested

    delegate :has_themis_validation?, :to => "self.class"
  eoruby
end