Class: Cenit::Collection::Base::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/cenit/collection/base/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_path) ⇒ Build

Returns a new instance of Build.



13
14
15
16
# File 'lib/cenit/collection/base/build.rb', line 13

def initialize (base_path)
  @base_path = base_path
  @collection_dep = []
end

Instance Attribute Details

#base_pathObject

Returns the value of attribute base_path.



10
11
12
# File 'lib/cenit/collection/base/build.rb', line 10

def base_path
  @base_path
end

#collection_depObject

Returns the value of attribute collection_dep.



11
12
13
# File 'lib/cenit/collection/base/build.rb', line 11

def collection_dep
  @collection_dep
end

Instance Method Details

#build_dataObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cenit/collection/base/build.rb', line 22

def build_data
  shared = {}
  hash = {}
  models = ['flows','connection_roles','translators','events','connections','webhooks']
  models.collect do |model|
    temp = []
    hash.merge!({model => []})
    @collection_dep.collect do |collection|
      temp = collection.process_model(model)
      hash.deep_merge!({model => temp}){ |_, val1, val2| array_sum(val1, val2) }
    end
     temp = process_model(model)
     hash.deep_merge!({model => temp}){ |_, val1, val2| array_sum(val1, val2) }
  end
  shared.merge!(hash)
  temp = []
  hash = {'libraries' => []}
  @collection_dep.collect do |collection|
    temp = collection.process_libraries
    hash.deep_merge!({'libraries' => temp}){ |_, val1, val2| array_sum(val1, val2) }
  end
    temp = process_libraries
    hash.deep_merge!({'libraries' => temp}){ |_, val1, val2| array_sum(val1, val2) }
  shared.merge!(hash)
  {"data" => shared}
end

#register_dep(dep) ⇒ Object



18
19
20
# File 'lib/cenit/collection/base/build.rb', line 18

def register_dep (dep)
  @collection_dep << dep
end

#shared_collectionObject



49
50
51
52
53
# File 'lib/cenit/collection/base/build.rb', line 49

def shared_collection
  shared = collection_base
  shared.deep_merge!(build_data)
  {"shared_collection" => shared}
end