Module: ForestLiana::QueryHelper
- Defined in:
- app/helpers/forest_liana/query_helper.rb
Class Method Summary collapse
- .get_one_association_names_string(resource) ⇒ Object
- .get_one_association_names_symbol(resource) ⇒ Object
- .get_one_associations(resource) ⇒ Object
- .get_tables_associated_to_relations_name(resource) ⇒ Object
Class Method Details
.get_one_association_names_string(resource) ⇒ Object
12 13 14 |
# File 'app/helpers/forest_liana/query_helper.rb', line 12 def self.get_one_association_names_string(resource) self.get_one_associations(resource).map { |association| association.name.to_s } end |
.get_one_association_names_symbol(resource) ⇒ Object
8 9 10 |
# File 'app/helpers/forest_liana/query_helper.rb', line 8 def self.get_one_association_names_symbol(resource) self.get_one_associations(resource).map(&:name) end |
.get_one_associations(resource) ⇒ Object
3 4 5 6 |
# File 'app/helpers/forest_liana/query_helper.rb', line 3 def self.get_one_associations(resource) SchemaUtils.one_associations(resource) .select { |association| SchemaUtils.model_included?(association.klass) } end |
.get_tables_associated_to_relations_name(resource) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/forest_liana/query_helper.rb', line 16 def self.get_tables_associated_to_relations_name(resource) tables_associated_to_relations_name = {} associations_has_one = self.get_one_associations(resource) associations_has_one.each do |association| if tables_associated_to_relations_name[association.table_name].nil? tables_associated_to_relations_name[association.table_name] = [] end tables_associated_to_relations_name[association.table_name] << association.name end tables_associated_to_relations_name end |