Class: Quarantini::Quarantine

Inherits:
Object
  • Object
show all
Defined in:
lib/quarantini/quarantine.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Quarantine

Returns a new instance of Quarantine.



32
33
34
35
36
# File 'lib/quarantini/quarantine.rb', line 32

def initialize(attributes = {})
  attributes.each do |name, value|
    send("#{name}=", value)
  end
end

Instance Attribute Details

#expires_atObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/quarantini/quarantine.rb', line 42

def expires_at
  case @expires_at
  when nil
    Date.today.next
  when String
    Date.parse(@expires_at)
  when Date
    @expires_at
  else
    raise ArgumentError, "Unknown expiry type #{@expires_at.class.name}.  Expecting one of (nil|String|Date)"
  end
end

Class Method Details

.mix_quarantini(quarantine_data) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/quarantini/quarantine.rb', line 21

def mix_quarantini(quarantine_data)
  if quarantine_data.nil?
    RELEASED
  elsif quarantine_data == true
    new
  else
    new(quarantine_data)
  end
end

.skip?(quarantine_data) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/quarantini/quarantine.rb', line 16

def skip?(quarantine_data)
  quarantine = mix_quarantini(quarantine_data)
  quarantine.skip?
end

Instance Method Details

#skip?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/quarantini/quarantine.rb', line 38

def skip?
  !Quarantini.config.run_all && expires_at >= Date.today
end