0.0
No release in over a year
Add "not given" default values to your objects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 2.19.2

Runtime

~> 0.2.4
 Project Readme

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

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