Exception: Contracts::ContractsNotIncluded

Inherits:
TypeError
  • Object
show all
Defined in:
lib/contracts/errors.rb

Overview

Error issued when user haven't included Contracts in original class but used Contract definition in singleton class

Provides useful description for user of the gem and an example of correct usage.

Constant Summary collapse

DEFAULT_MESSAGE =
%{In order to use contracts in singleton class, please include Contracts module in original class
Example:

```ruby
class Example
  include Contracts  # this line is required
  class << self
    # you can use `Contract` definition here now
  end
end
```}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = DEFAULT_MESSAGE) ⇒ ContractsNotIncluded

Returns a new instance of ContractsNotIncluded.


69
70
71
72
# File 'lib/contracts/errors.rb', line 69

def initialize(message = DEFAULT_MESSAGE)
  super
  @message = message
end

Instance Attribute Details

#messageObject (readonly) Also known as: to_s

Returns the value of attribute message


66
67
68
# File 'lib/contracts/errors.rb', line 66

def message
  @message
end