Skip to content

Commit

Permalink
Merge pull request #226 from rapid7/blackout_site_load_fix
Browse files Browse the repository at this point in the history
Fix hash failure for non-recurring blackouts

Resolves #225
  • Loading branch information
gschneider-r7 authored Aug 26, 2016
2 parents 51d0db9 + 5cc3b4d commit 187baa4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/nexpose/blackout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ class Blackout < APIObject
attr_accessor :blackout_duration

def initialize(start, enabled=true, duration, type, interval)
@blackout_start = start
@enabled =enabled
@blackout_start = start
@enabled = enabled
@blackout_duration = duration.to_i
@blackout_type = type
@blackout_type = type
@blackout_interval = interval.to_i
end

def self.from_hash(hash)
repeat_blackout_hash = hash[:repeat_blackout]
blackout = new(hash[:start_date], hash[:blackout_duration], repeat_blackout_hash[:type], repeat_blackout_hash[:interval])
blackout

if repeat_blackout_hash.nil?
type = 'daily'
interval = 0
else
type = repeat_blackout_hash[:type]
interval = repeat_blackout_hash[:interval]
end

new(hash[:start_date], hash[:blackout_duration], type, interval)
end

def to_h
Expand All @@ -42,4 +50,4 @@ def to_h
blackout_hash
end
end
end
end

0 comments on commit 187baa4

Please sign in to comment.