Module: Cardia::Validateable

Included in:
CreditCard
Defined in:
lib/cardia/validateable.rb

Overview

Implements the standard ActiveRecord stuff for non-AR classes

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#errorsObject



18
19
20
# File 'lib/cardia/validateable.rb', line 18

def errors    
  @errors ||= Error.new(self)
end

#initialize(attributes = {}) ⇒ Object



14
15
16
# File 'lib/cardia/validateable.rb', line 14

def initialize(attributes = {})
  self.attributes = attributes
end

#valid?Boolean

:nodoc:

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
# File 'lib/cardia/validateable.rb', line 5

def valid?
  errors.clear

  before_validate if respond_to?(:before_validate)
  validate if respond_to?(:validate)

  errors.empty?
end