Sha256: 47d423b37caf772c93431a28f2973a6bb2aa51d8920ebdb902f4507d07c6b560

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

# MuchNotGiven

Add "not given" default values to your objects. This allows you to safely detect whether a method has been given argument values or not.

## Usage

```ruby
module MyNamespace
  include MuchNotGiven
end

MyNamespace.not_given                           # => MyNamespace.not_given
"some value" == MyNamespace.not_given           # => false
MyNamespace.not_given?("some value")            # => false
MyNamespace.not_given?(MyNamespace.not_given?)  # => true
MyNamespace.given?("some value")                # => true
MyNamespace.given?(MyNamespace.not_given?)      # => false

def my_method(value = MyNamespace.not_given)
  if MyNamespace.given?(value)
    # do something with the given value
  end
end

def my_method(arg_value = MyNamespace.not_given)
  value = MyNamespace.given?(value) ? value : "some default value"

  # do something with the optionally defaulted value
end
```

## Installation

Add this line to your application's Gemfile:

    gem "much-not-given"

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install much-not-given

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am "Added some feature"`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
much-not-given-0.1.3 README.md
much-not-given-0.1.2 README.md
much-not-given-0.1.1 README.md
much-not-given-0.1.0 README.md