Module: Magpie::Goose

Included in:
AlipayModel, ChinabankModel, TenpayModel
Defined in:
lib/magpie/goose.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(m)



12
13
14
# File 'lib/magpie/goose.rb', line 12

def self.included(m)
  m.extend ClassMethods
end

Instance Method Details

- (Object) errors



73
74
75
# File 'lib/magpie/goose.rb', line 73

def errors
  @errors ||= Hash.new{ |h, k| h[k.to_sym] = []}
end

- (Goose) initialize(attributes = {})

A new instance of Goose



5
6
7
8
9
10
# File 'lib/magpie/goose.rb', line 5

def initialize(attributes = {})
  @attributes = attributes
  attributes.each do |name, value|
    send("#{name}=", value) if respond_to? name
  end
end

- (Boolean) valid?

Returns:

  • (Boolean)


81
82
83
84
# File 'lib/magpie/goose.rb', line 81

def valid?
  @validated ||= validating
  self.errors.values.flatten.empty?
end

- (Object) validating



77
78
79
# File 'lib/magpie/goose.rb', line 77

def validating
  self.class.validations.each {|v| String === v ? self.send(v) : v.call(self) }
end