Exception: Builderator::Util::LimitException

Inherits:
TaskException
  • Object
show all
Defined in:
lib/builderator/util/limit_exception.rb

Overview

Exception raised if a safety limit is exceeded

Instance Attribute Summary collapse

Attributes inherited from TaskException

#status, #task

Instance Method Summary collapse

Constructor Details

#initialize(klass, task, resources) ⇒ LimitException

Returns a new instance of LimitException.



11
12
13
14
15
16
# File 'lib/builderator/util/limit_exception.rb', line 11

def initialize(klass, task, resources)
  super(:limit, task, :yellow)

  @klass = klass
  @resources = resources
end

Instance Attribute Details

#resourcesObject (readonly)

Returns the value of attribute resources.



9
10
11
# File 'lib/builderator/util/limit_exception.rb', line 9

def resources
  @resources
end

Instance Method Details

#countObject



18
19
20
# File 'lib/builderator/util/limit_exception.rb', line 18

def count
  @resources.size
end

#limitObject



22
23
24
# File 'lib/builderator/util/limit_exception.rb', line 22

def limit
  @klass::LIMIT
end

#messageObject



30
31
32
33
34
35
# File 'lib/builderator/util/limit_exception.rb', line 30

def message
  "Safety limit exceeded for task `#{ task }`: Count #{ count } is"\
  " greater than the limit of #{ limit } set in #{ resource }. Please"\
  " re-run this task with the --no-limit flag if you are sure this is"\
  " the correct set of resources to delete."
end

#resourceObject



26
27
28
# File 'lib/builderator/util/limit_exception.rb', line 26

def resource
  @klass.name
end