0.0
No release in over 3 years
Low commit activity in last 3 years
Unavailability simply adds a capability to manage availabilities.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 10.0
~> 5.0
~> 10.0
~> 3.0
~> 1.3

Runtime

 Project Readme

Build Status

Unavailability

Unavailability simply adds a capability to manage availabilities. I extracted this gem from the work I am doing for ehochef.com where I have to allow a user to make their day either available or unavailable via a calendar (I use simple_calendar for UI).

Since we want to keep a user's availability available by default, managing i.e. adding/removing "unavailability" rather than "availability" makes sense to me; hence, the name of the gem and the logic followed in the code.

Installation

Add this line to your application's Gemfile:

gem "unavailability"

And then execute:

bundle install

Generate a migration file to create the unavailable_dates table:

rails generate unavailable_date

Run the migration:

rails db:migrate

Edit a Model as the following:

# Since it is a Polymorphic association, it can be added to any number of Models
class User < ApplicationRecord
  include Unavailability
end

Usage

Check if the model is available for a Date:

  user.available_for_date?(Date.today)

Return all available Users:

  User.available_for_date(Date.today)

Make a Date range unavailable:

  user.make_available(from: Date.parse('2050-01-10'), to: Date.parse('2050-01-15'))

Make a Date range available:

  user.make_unavailable(from: Date.parse('2050-01-08'), to: Date.parse('2050-01-08'))

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/unavailability. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Unavailability project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.