Module: Kraut::Mapper

Included in:
Principal, Session
Defined in:
lib/kraut/mapper.rb

Overview

Kraut::Mapper

Contains methods for mapping attributes.

Instance Method Summary collapse

Instance Method Details

#initialize(attributes = nil) ⇒ Object

Accepts a Hash of attributes and assigns them via writer methods. Calls an after_initialize method if available.



10
11
12
# File 'lib/kraut/mapper.rb', line 10

def initialize(attributes = nil)
  mass_assign! attributes
end

#mass_assign!(attributes) ⇒ Object

Expects a Hash of attributes and assigns them via attribute writers.



15
16
17
# File 'lib/kraut/mapper.rb', line 15

def mass_assign!(attributes)
  attributes.each { |key, value| send "#{key}=", value } if attributes
end