Module: Build::Denormalize

Defined in:
lib/travis/model/build/denormalize.rb

Constant Summary collapse

DENORMALIZE =
{
  :start  => %w(id number status started_at finished_at),
  :finish => %w(status finished_at)
}

Instance Method Summary collapse

Instance Method Details

#denormalize(event, *args) ⇒ Object



3
4
5
# File 'lib/travis/model/build/denormalize.rb', line 3

def denormalize(event, *args)
  repository.update_attributes!(denormalize_attributes_for(event)) if denormalize?(event)
end

#denormalize?(event) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/travis/model/build/denormalize.rb', line 12

def denormalize?(event)
  DENORMALIZE.key?(event)
end

#denormalize_attributes_for(event) ⇒ Object



16
17
18
19
20
# File 'lib/travis/model/build/denormalize.rb', line 16

def denormalize_attributes_for(event)
  DENORMALIZE[event].inject({}) do |result, key|
    result.merge(:"last_build_#{key}" => send(key))
  end
end