Skip to content
A DataMapper plugin for adding predefined resources to Models.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.document
.gitignore
.rspec
.yardopts
ChangeLog.md
Gemfile
LICENSE.txt
README.md
Rakefile
dm-is-predefined.gemspec
gemspec.yml

README.md

dm-is-predefined

Description

A DataMapper plugin for adding predefined resources to Models.

Example

require 'dm-core'
require 'dm-is-predefined'

class Licence

  include DataMapper::Resource

  is :predefined

  # Name of the Licence
  property :name, String

  # URL to the licence
  property :url, String

  predefine :gpl2,
            :name => 'GPL-2',
            :url => 'http://www.gnu.org/copyleft/gpl.html'

  predefine :mit, :name => 'MIT'

end

Licence.gpl2
# => #<Licence: id: 1, name: "GPL-2", url: "http://www.gnu.org/copyleft/gpl.html">

Licence.predefined_resource(:mit)
# => #<Licence: id: 2, name: "MIT">

License.predefined_resource_with(:name => 'GPL-2')
# => #<License: id: 1, name: "GPL-2", url: "http://www.gnu.org/copyleft/gpl.html">

License.predefined?(:gpl2)
# => true

License.predefined
# => [:gpl2, :mit]

Requirements

Install

$ sudo gem install dm-is-predefined

License

Copyright (c) 2008-2011 Hal Brodigan

See {file:LICENSE.txt} for license information.

Something went wrong with that request. Please try again.