Class: FmStore::Builders::Single
- Inherits:
-
Object
- Object
- FmStore::Builders::Single
- Defined in:
- lib/fm_store/builders/single.rb
Class Method Summary collapse
Class Method Details
.build(records, model) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fm_store/builders/single.rb', line 5 def self.build(records, model) record = records.first fm_fields = record.keys obj = model.new fm_fields.each do |fm_field| field = model.fields[fm_field] # Field obj.instance_variable_set("@#{field.name}", record[fm_field]) end obj.instance_variable_set("@new_record", false) obj.instance_variable_set("@mod_id", record.mod_id) obj.instance_variable_set("@record_id", record.record_id) return obj end |