Skip to content
This repository has been archived by the owner on Feb 28, 2021. It is now read-only.

postmodern/dm-is-predefined

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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


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

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

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.first_or_predefined(:name => 'GPL-2')
# => #<License: id: 1, name: "GPL-2", url: "http://www.gnu.org/copyleft/gpl.html">

Requirements

Install

$ gem install dm-is-predefined

License

Copyright (c) 2008-2011 Hal Brodigan

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

About

A DataMapper plugin for adding predefined resources to Models.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages