Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A DataMapper plugin for adding predefined resources to Models.

tag: semver

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .specopts
Octocat-spinner-32 .yardopts
Octocat-spinner-32 ChangeLog.md
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 dm-predefined.gemspec
README.md

dm-predefined

Description

A DataMapper plugin for adding predefined resources to Models.

Example

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

class Licence

  include DataMapper::Resource
  include DataMapper::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_names
# => [:gpl2, :mit]

Requirements

Install

$ sudo gem install dm-predefined

License

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

Something went wrong with that request. Please try again.