Sha256: a53813d22012dd45baded029425d0546effd7d2402c4a3de504d7d0fc2d81052

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

# ActiveWarnings

`ActiveModel::Validations` separate for warnings.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'active_warnings'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install active_warnings

## Usage

```ruby
class BasicModel
  include ActiveWarnings

  attr_accessor :name, :warning_name

  validates :name, presence: true

  warnings do
    # to use same validators,
    # calling #valid? or #errors will be #no_errors? and #warnings, respectively (on self or record)
    validates :warning_name, presence: true
  end
end

model = BasicModel.new(name: "a")
model.valid? # => true
model.errors.keys # => []

model.safe? # => false
model.no_warnings? # => false, equivalent to #safe?
model.warnings.keys # => [:warning_name]

model.using_warnings? # => false, is true if warnings are used (within #safe call)

```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_warnings-0.1.2 README.md