Sha256: 38a3df2f1cb2fc232631aa242395294bfb51cf4e82c05c8a88736a87ed20231f

Contents?: true

Size: 1.01 KB

Versions: 156

Compression:

Stored size: 1.01 KB

Contents

module ForestLiana
  module QueryHelper
    def self.get_one_associations(resource)
      SchemaUtils.one_associations(resource)
        .select { |association| SchemaUtils.model_included?(association.klass) }
    end

    def self.get_one_association_names_symbol(resource)
      self.get_one_associations(resource).map(&:name)
    end

    def self.get_one_association_names_string(resource)
      self.get_one_associations(resource).map { |association| association.name.to_s }
    end

    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
  end
end

Version data entries

156 entries across 156 versions & 1 rubygems

Version Path
forest_liana-8.0.0.beta.4 app/helpers/forest_liana/query_helper.rb
forest_liana-8.0.0.beta.3 app/helpers/forest_liana/query_helper.rb
forest_liana-8.0.0.beta.2 app/helpers/forest_liana/query_helper.rb
forest_liana-8.0.0.beta.1 app/helpers/forest_liana/query_helper.rb
forest_liana-7.8.0 app/helpers/forest_liana/query_helper.rb
forest_liana-7.7.3 app/helpers/forest_liana/query_helper.rb
forest_liana-7.7.2 app/helpers/forest_liana/query_helper.rb
forest_liana-7.7.1 app/helpers/forest_liana/query_helper.rb
forest_liana-7.7.0 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.14 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.13 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.12 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.11 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.10 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.9 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.8 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.7 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.6 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.5 app/helpers/forest_liana/query_helper.rb
forest_liana-7.6.4 app/helpers/forest_liana/query_helper.rb