Sha256: 34a4b506168ee2900f7d4644cddd40c28bc68bed2188ad2d9ba16afeb791aba2

Contents?: true

Size: 1009 Bytes

Versions: 116

Compression:

Stored size: 1009 Bytes

Contents

module ForestLiana
  class BaseGetter
    def get_collection(collection_name)
      ForestLiana.apimap.find { |collection| collection.name.to_s == collection_name }
    end

    def get_resource
      use_act_as_paranoid = @resource.instance_methods
        .include? :really_destroyed?

      # NOTICE: Do not unscope with the paranoia gem to prevent the retrieval
      #         of deleted records.
      use_act_as_paranoid ? @resource : @resource.unscoped
    end

    def includes_for_serialization
      includes_initial = @includes
      includes_for_smart_belongs_to = @collection.fields_smart_belongs_to.map { |field| field[:field] }

      if @field_names_requested
        includes_for_smart_belongs_to = includes_for_smart_belongs_to & @field_names_requested
      end

      includes_initial.concat(includes_for_smart_belongs_to).map(&:to_s)
    end

    private

    def compute_includes
      @includes = ForestLiana::QueryHelper.get_one_association_names_symbol(@resource)
    end
  end
end

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
forest_liana-7.6.3 app/services/forest_liana/base_getter.rb
forest_liana-7.6.2 app/services/forest_liana/base_getter.rb
forest_liana-7.6.1 app/services/forest_liana/base_getter.rb
forest_liana-7.6.0 app/services/forest_liana/base_getter.rb
forest_liana-7.5.1 app/services/forest_liana/base_getter.rb
forest_liana-7.5.0 app/services/forest_liana/base_getter.rb
forest_liana-7.4.5 app/services/forest_liana/base_getter.rb
forest_liana-7.4.4 app/services/forest_liana/base_getter.rb
forest_liana-7.4.3 app/services/forest_liana/base_getter.rb
forest_liana-7.4.2 app/services/forest_liana/base_getter.rb
forest_liana-7.4.1 app/services/forest_liana/base_getter.rb
forest_liana-7.4.0 app/services/forest_liana/base_getter.rb
forest_liana-7.3.0 app/services/forest_liana/base_getter.rb
forest_liana-6.6.3 app/services/forest_liana/base_getter.rb
forest_liana-7.2.2 app/services/forest_liana/base_getter.rb
forest_liana-7.2.1 app/services/forest_liana/base_getter.rb
forest_liana-7.2.0 app/services/forest_liana/base_getter.rb
forest_liana-7.1.0 app/services/forest_liana/base_getter.rb
forest_liana-7.0.2 app/services/forest_liana/base_getter.rb
forest_liana-7.0.1 app/services/forest_liana/base_getter.rb