Module: MerbMerchant::Validateable

Included in:
Billing::Check, Billing::CreditCard
Defined in:
lib/merb_merchant/lib/validateable.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Errors

Instance Method Summary collapse

Instance Method Details

#errorsObject



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

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

#initialize(attributes = {}) ⇒ Object



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

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

#valid?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
# File 'lib/merb_merchant/lib/validateable.rb', line 3

def valid?
  errors.clear

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

  errors.empty?
end