Module: ForestLiana::AdapterHelper
- Defined in:
- app/helpers/forest_liana/adapter_helper.rb
Constant Summary collapse
- ADAPTER_MYSQL2 =
'Mysql2'
Class Method Summary collapse
- .cast_boolean(value) ⇒ Object
- .format_column_name(table_name, column_name) ⇒ Object
- .format_live_query_line_result(result) ⇒ Object
- .format_live_query_pie_result(result) ⇒ Object
- .format_live_query_value_result(result) ⇒ Object
Class Method Details
.cast_boolean(value) ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/helpers/forest_liana/adapter_helper.rb', line 11 def self.cast_boolean(value) if ['MySQL', 'SQLite'].include?(ActiveRecord::Base.connection.adapter_name) value === 'true' ? 1 : 0 else value end end |
.format_column_name(table_name, column_name) ⇒ Object
5 6 7 8 9 |
# File 'app/helpers/forest_liana/adapter_helper.rb', line 5 def self.format_column_name(table_name, column_name) quoted_table_name = ActiveRecord::Base.connection.quote_table_name(table_name) quoted_column_name = ActiveRecord::Base.connection.quote_column_name(column_name) "#{quoted_table_name}.#{quoted_column_name}" end |
.format_live_query_line_result(result) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/forest_liana/adapter_helper.rb', line 39 def self.format_live_query_line_result(result) # NOTICE: The adapters have their own specific format for the live query line chart results. case ActiveRecord::Base.connection.adapter_name when ADAPTER_MYSQL2 result.map { |value| { 'key' => value[0], 'value' => value[1] } } else result end end |
.format_live_query_pie_result(result) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/forest_liana/adapter_helper.rb', line 29 def self.format_live_query_pie_result(result) # NOTICE: The adapters have their own specific format for the live query pie chart results. case ActiveRecord::Base.connection.adapter_name when ADAPTER_MYSQL2 result.map { |value| { 'key' => value[0], 'value' => value[1] } } else result.to_a end end |
.format_live_query_value_result(result) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/forest_liana/adapter_helper.rb', line 19 def self.format_live_query_value_result(result) # NOTICE: The adapters have their own specific format for the live query value chart results. case ActiveRecord::Base.connection.adapter_name when ADAPTER_MYSQL2 { 'value' => result.first.first } else result.first end end |