Class: Validbot::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/validbot.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, &block) ⇒ Validator

Returns a new instance of Validator.



15
16
17
18
19
20
21
22
# File 'lib/validbot.rb', line 15

def initialize(object, &block)
  klass(object).class_eval do
    include ::ActiveModel::Validations
  end

  klass(object).class_eval(&block)
  self
end

Class Method Details

.validate(object, &block) ⇒ Object



11
12
13
# File 'lib/validbot.rb', line 11

def self.validate(object, &block)
  self.new(object, &block)
end