Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/postmodern/dm-is-indexed


https://github.com/postmodern/dm-is-indexed

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# dm-is-indexed

* [Homepage](http://github.com/postmodern/dm-is-indexed#readme)
* [Issues](http://github.com/postmodern/dm-is-indexed/issues)
* [Documentation](http://rubydoc.info/gems/dm-is-indexed/frames)
* [Email](mailto:postmodern.mod3 at gmail.com)

## Description

dm-is-indexed overloads the `Model[]` method, and allows querying Resources
using their indexed properties.

## Examples

require 'dm-is-indexed'

class Atom

include DataMapper::Resource

is :indexed

property :id, Serial

property :symbol, String, :unique => true

property :name, String, :unique => true

property :atomic_weight, Float, :index => true

end

Traditional Array style access is preserved:

Atom[0]
# => #

Atom[0,1]
# => [#,
#]

Query Resources based on their unique indexed properties:

Atom["Kr"]
# => #

Atom["Krpton"]
# => #

Atom[83.798]
# => #

## Requirements

* [dm-core](http://github.com/datamapper/dm-core#readme) ~> 1.0

## Install

$ gem install dm-is-indexed

## Copyright

Copyright (c) 2011 Hal Brodigan

See {file:LICENSE.txt} for details.