lib/domain/model.rb in avs-0.1.0 vs lib/domain/model.rb in avs-0.1.1
- old
+ new
@@ -41,11 +41,22 @@
def self.table_name
name.underscore
end
+ def self.view
+ "#{table_name}_view"
+ end
+
def self.from_json(data)
- new(data.transform_keys(&:to_sym)) # Transform keys from string to symbols if necessary
+ transformed_data = data.transform_keys do |key|
+ key.to_s.underscore.to_sym
+ end
+ new(transformed_data)
+ end
+
+ def self.from_csv(row)
+ from_json(row.to_h)
end
def to_s
self.class.columns.map { |attr| send(attr) }.join(',')
end