Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A DataMapper plugin for making a Model absolutely read-only.
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.yardopts
ChangeLog.md
Gemfile
LICENSE.txt
README.md
Rakefile
dm-is-read_only.gemspec
gemspec.yml

README.md

dm-is-read_only

Description

A DataMapper plugin for making Models absolutely read-only.

Features

  • Ignores auto-migrations on read-only Models.
  • Ignores auto-upgrades on read-only Models.
  • Puts all resources of a read-only Model into the Immutable state.
  • Supports the :migrations and :mutable options for selectively enabling migrations or mutability.

Example

require 'dm-core'
require 'dm-is-read_only'

class Licence

  include DataMapper::Resource

  is :read_only

  # The primary-key of the License
  property :id, Serial

  # Name of the Licence
  property :name, String

  # URL to the licence
  property :url, String

end

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

# ignores auto-migrations
License.auto_migrate!
# => true

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

# ignores auto-upgrades
License.auto_upgrade!
# => true

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

license.name = 'WTF'
license.save!
# => true

# will not allow saving resources
license.reload
license.name
# => "GPL-2"

license.destroy!
# => true

# will not allow destroying resources
license = License.first
# => #<Licence: id: 1, name: "GPL-2", url: "http://www.gnu.org/copyleft/gpl.html">

Requirements

Install

$ sudo gem install dm-is-read_only

License

Copyright (c) 2010-2012 Hal Brodigan

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

Something went wrong with that request. Please try again.