Module: ZooniverseData::Helpers::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/zooniverse_data/helpers/base.rb

Instance Method Summary collapse

Instance Method Details

#_new_location_from(result) ⇒ Object



49
50
51
# File 'lib/zooniverse_data/helpers/base.rb', line 49

def _new_location_from(result)
  result.respond_to?(:path) ? result.path : result
end

#customize(manifest: nil, entry: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/zooniverse_data/helpers/base.rb', line 11

def customize(manifest: nil, entry: nil)
  self.manifest = manifest
  self.entry = entry
  
  if entry.subject?
    customize_subject
  elsif entry.group?
    customize_group
  end
end

#customize_groupObject



26
27
28
# File 'lib/zooniverse_data/helpers/base.rb', line 26

def customize_group
  
end

#customize_subjectObject



22
23
24
# File 'lib/zooniverse_data/helpers/base.rb', line 22

def customize_subject
  
end

#each_locationObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/zooniverse_data/helpers/base.rb', line 30

def each_location
  new_locations = { }
  entry.location.each_pair do |key, value|
    new_locations[key] = if value.is_a?(Array)
      value.collect do |location|
        _new_location_from yield(key, location)
      end
    else
      _new_location_from yield(key, value)
    end
  end
  
  set_location new_locations
end

#set_location(hash) ⇒ Object



45
46
47
# File 'lib/zooniverse_data/helpers/base.rb', line 45

def set_location(hash)
  entry.update :$set => { location: hash }
end