Coder Social home page Coder Social logo

reservation's Introduction

Reservation

A gem for managing reservations. Provides the notion of "Event", which is basically an interval in time, and a "Reservation", which is a many-to-many association model between Event and your objects.

There is no privileged event "owner", all associations are considered equivalent.

This gem uses ActiveRecord to store events and reservations

Installation

Add this line to your application's Gemfile:

gem 'reservation'

And then execute:

$ bundle

Or install it yourself as:

$ gem install reservation

Usage

First of all migrate your schema so you have the necessary tables -

rails g reservation:migration

Objects associated with an event are called "subjects"; each event has many subjects, via an association model called Reservation::Reservation. The simplest way to create a bunch of events is to use Event#create_weekly. This will create a set of events, with the given subjects, within the given constraints, repeating weekly.

subjects = [ { "role" => "owner", "subject" => matt, "status" => "confirmed" },
             { "role" => "helpr", "subject" => bill, "status" => "tentative" },
             { "role" => "place", "subject" => here, "status" => "tentative" }
           ]

pattern = [ { "day" => "wed", "start" => "0930", "finish" => "1030"},
            { "day" => "wed", "start" => "18",   "finish" => "20"  },
            { "day" => "tue", "start" => "7",    "finish" => "830" } ]

Reservation::Event.create_weekly "the_title", "2013-09-03", "2013-10-13", subjects, pattern

You can use Reservation::Event#build_weekly instead in order to instantiate the object graph without persisting it.

Contributing

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

license

MIT License

reservation's People

Contributors

conanite avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.