Method: Docman::Info#initialize

Defined in:
lib/docman/info.rb

#initialize(hash = {}) ⇒ Info

Returns a new instance of Info.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/docman/info.rb', line 10

def initialize(hash = {})
  super
  hash.each_pair do |k, v|
    self[k] = v
  end
  self['build_type'] = self['docroot_config'].deploy_target['builders'][self['type']]['handler'] unless self['docroot_config'].deploy_target.nil?
  @need_rebuild = Hash.new
  @changed = Hash.new
  @state_name = nil
  unless self['docroot_config'].deploy_target.nil?
    if self.has_key? 'states'
      self['states'].each_pair do |name, state|
        if state.has_key?('source')
          if state['source']['type'] == :retrieve_from_repo
            @state_name = name
            repo = state['source']['repo'] == :project_repo ? self['repo'] : state['source']['repo']
            external_state_info = read_yaml_from_file(repo, self['states_path'], state['source']['branch'], state['source']['file'])
            state.deep_merge! external_state_info unless external_state_info.nil? or state.nil?
          end
        end
      end
    end
  end
end