lib/fin/models/model.rb in fin-0.1.5 vs lib/fin/models/model.rb in fin-0.1.6
- old
+ new
@@ -51,11 +51,11 @@
case type
# TODO: Using indexes (...ByIndex) instead of names gives ~60% speed boost
when /^i[14]/
"rec.GetValAsLong('#{name}')"
when /^i8/
- "rec.GetValAsString('#{name}').to_i"
+ "rec.GetValAsVariant('#{name}')"
when /^[df]/
"rec.GetValAsString('#{name}').to_f"
when /^[c]/
"rec.GetValAsString('#{name}')"
when /^[t]/ # "2009/12/01 12:35:44.785" => 20091201123544785
@@ -83,17 +83,17 @@
model_classes[class_id].new *msg[1..-1]
end
# Extracts attributes from record into a serializable format (Array)
# Returns an Array where 1st element is a model_class_id of our Model subclass,
- # and second element is a list of arguments to its initialize. Class method!
+ # followed by a list of arguments to its initialize. Class method!
def self.to_msg rec
extract_attributes(rec).unshift(model_class_id)
end
# Converts OBJECT attributes into a serializable format (Array)
# Returns an Array where 1st element is a model_class_id of our Model subclass,
- # and second element is a list of arguments to its initialize. Instance method!
+ # followed by a list of arguments to its initialize. Instance method!
def to_msg
inject([self.class.model_class_id]) { |array, (name, _)| array << send(name) }
end
# TODO: Builder pattern, to avoid args Array creation on each initialize?