Sha256: 85f952d941a6275c008ec984b337a475448534f18987eedd38a963e5f2945515

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

# orc

[![Gem Version](https://badge.fury.io/rb/orc.png)][gem]
[![Build Status](https://secure.travis-ci.org/snusnu/orc.png?branch=master)][travis]
[![Dependency Status](https://gemnasium.com/snusnu/orc.png)][gemnasium]
[![Code Climate](https://codeclimate.com/github/snusnu/orc.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/snusnu/orc/badge.png?branch=master)][coveralls]

[gem]: https://rubygems.org/gems/orc
[travis]: https://travis-ci.org/snusnu/orc
[gemnasium]: https://gemnasium.com/snusnu/orc
[codeclimate]: https://codeclimate.com/github/snusnu/orc
[coveralls]: https://coveralls.io/r/snusnu/orc

## Usage

Whenever you want to communicate success or failure of an operation, the following might be handy

```ruby
describe Orc::Result do
  describe '.success' do
    subject { Orc::Result.success(object) }

    let(:object) { :object }

    it 'signals success' do
      expect(subject.success?).to be(true)
    end

    it 'returns :success state' do
      expect(subject.status).to be(:success)
    end

    it 'exposes the associated object' do
      expect(subject.object).to be(object)
    end
  end

  describe '.failure' do
    subject { Orc::Result.failure(status, context) }

    let(:status)  { :confused }
    let(:context) { :context }

    it 'signals failure' do
      expect(subject.success?).to be(false)
    end

    it 'returns :success state' do
      expect(subject.status).to be(status)
    end

    it 'exposes the associated context' do
      expect(subject.context).to be(context)
    end
  end
end
```

## Credits

* [snusnu](https://github.com/snusnu)

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for details.

## Copyright

Copyright © 2014 Martin Gamsjaeger (snusnu). See [LICENSE](LICENSE) for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
orc-0.0.1 README.md