Giter VIP home page Giter VIP logo

collectable's Introduction

Collectable

So, I serialize stuff into arrays in my AR objects where it doesn't make sense to go through the rigamaroe of actually making an empty AR model to use for the association. This is just a bit of glue to make using that pattern a bit easier with

There's not much to this thing, and what's there exists only to serve the needs that I've had for this sort of thing.

That said, pull requests are totally welcome :)

Gem Setup

gem install collectable

# Gemfile
gem 'collectable'

Basic usage

The short version is "include the module and define some characteristics." That's also the long version, as it were.

class HairColor
  include Collectable

  characteristic :blonde
  characteristic :brown
  characteristic :red
  characteristic :black
  characteristic :purple
  characteristic :tie_dye
end

Then, to actually use the thing, do something like this in your view:

<%= form_for @person do |f| %>
  <%= f.collection_check_boxes(:hair_color, HairColor.collected, HairColor.value, HairColor.name) %>
<% end %>

Contributing

Do you use git-flow? I sure do. Please base anything you do off of the develop branch.

  1. Fork it.
  2. Perform some BDD magic. Seriously. Be testing.
  3. Submit a pull request.

History

  • 0.0.4 - Renamed "traits" to "characteristics"
  • 0.0.3 - .value and .name actually added
  • 0.0.2 - Renamed collected_item#val to collected_item#value
  • 0.0.1 - Public release

License

MIT License. Copyright 2014 Dennis Walters

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.