Method: Sequel::Model#initialize
- Defined in:
- lib/sequel_model/record.rb
#initialize(values = nil, from_db = false) {|_self| ... } ⇒ Model
Creates new instance with values set to passed-in Hash. If a block is given, yield the instance to the block. This method runs the after_initialize hook after it has optionally yielded itself to the block.
Arguments:
-
values - should be a hash with symbol keys, though string keys will work if from_db is false.
-
from_db - should only be set by Model.load, forget it exists.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sequel_model/record.rb', line 28 def initialize(values = nil, from_db = false, &block) values ||= {} @changed_columns = [] @typecast_on_assignment = model.typecast_on_assignment @db_schema = model.db_schema if from_db @new = false @values = values else @values = {} @new = true set_with_params(values) end @changed_columns.clear yield self if block after_initialize end |