Class: Trackplot::DataAdapter
- Inherits:
-
Object
- Object
- Trackplot::DataAdapter
- Defined in:
- lib/trackplot/data_adapter.rb
Class Method Summary collapse
Class Method Details
.normalize(data) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/trackplot/data_adapter.rb', line 3 def self.normalize(data) records = case data when ->(d) { defined?(ActiveRecord::Relation) && d.is_a?(ActiveRecord::Relation) } data.map { |record| to_string_hash(record.attributes) } when Array data.map { |item| coerce_record(item) } when Hash [data.transform_keys(&:to_s)] else Array(data).map { |item| coerce_record(item) } end records.map { |r| r.transform_keys(&:to_s) } end |