Repository is archived
No commit activity in last 3 years
No release in over 3 years
A DataMapper plugin for adding predefined resources to Models.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 0.7.0

Runtime

~> 1.0
 Project Readme

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.