Sha256: b04ead3629d1ab3ae00dc887d447dfc8db1a976879f3b3f4bbe8712c8e9ca90d

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

Reply
======

A simple class used to encapsulate the reply from a service

[![Build Status](https://travis-ci.org/sporto/reply.png)](https://travis-ci.org/sporto/reply)

Usage
-----

```ruby
  reply = Reply.new

  # add message
  reply.add_message("Something")

  # add multiple messages
  reply.add_messages(["x", "y"])

  # mark the reply as succesful (this is the default)
  reply.success!

  # mark as warning
  reply.warning!

  # mark as error
  reply.error!

  # add error message and mark as error at the same time
  reply.add_error("Something bad happend")

  # add erroor messages and mark as error
  reply.add_error(["Error 1", "Error 2"])

  # check if reply was successful
  reply.successful?
  reply.success?

  # check if reply was unsuccessful
  reply.error?
  reply.failure?

  # add some data to the reply
  reply.data = something

  # add a status to the reply
  # this is independent of success, error and warning
  reply.status = 401

  # copy all the errors from an active record object
  reply.replace_messages_with_errors_for(active_record_object)
```

Copyright
---------
Copyright © 2013 Sebastian Porto. See LICENSE.txt for further details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reply-0.3.0 readme.md