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.



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

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

Instance Attribute Details

#messageObject (readonly) Also known as: to_s

Returns the value of attribute message.



64
65
66
# File 'lib/contracts/errors.rb', line 64

def message
  @message
end