Exception: Omnibus::MissingRequiredAttribute

Inherits:
Error
  • Object
show all
Defined in:
lib/omnibus/exceptions.rb

Instance Method Summary collapse

Constructor Details

#initialize(instance, name, sample = '<VALUE>') ⇒ MissingRequiredAttribute

Returns a new instance of MissingRequiredAttribute



49
50
51
52
# File 'lib/omnibus/exceptions.rb', line 49

def initialize(instance, name, sample = '<VALUE>')
  @instance, @name, @sample = instance, name, sample
  @class = instance.class.name.split('::').last
end

Instance Method Details

#to_sObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/omnibus/exceptions.rb', line 54

def to_s
  <<-EOH
Missing required attribute `#{@name}' for #{@class}. You must
specify a value for `#{@name}' in your DSL file:

#{@name} #{@sample.inspect}

Or set the value on the object:

#{@class.downcase}.#{@name}(#{@sample.inspect})
EOH
end