Class: ForestLiana::BaseGetter

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/base_getter.rb

Instance Method Summary collapse

Instance Method Details

#get_collection(collection_name) ⇒ Object



3
4
5
# File 'app/services/forest_liana/base_getter.rb', line 3

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

#get_resourceObject



7
8
9
10
11
12
13
14
# File 'app/services/forest_liana/base_getter.rb', line 7

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

#includes_for_serializationObject



16
17
18
19
20
21
22
23
24
25
# File 'app/services/forest_liana/base_getter.rb', line 16

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