Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A DataMapper plugin which adds configuration to resources
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec initial implementation of configuration cache
tasks
History.txt
LICENSE
Manifest.txt
README.markdown
README.txt
Rakefile
TODO

README.markdown

dm-is-configurable

Disclaimer

THIS IS A WORK-IN-PROGRESS!

The plugin allows you to add configuration to your models.

Example usage:

require 'dm-is-configurable'

class Kitteh
  include DataMapper::Resource

  property :id, Serial
  property :name, String

  is :configurable, :with => { 
    :cheezburger_limit => 10, 
    :be_cute => true
  }
end

# create configuration options for kittehs
Kitteh.auto_migrate!
Kitteh.setup_configuration

cute_one = Kitteh.create(:name => 'Cute Kitteh')
ugly_one = Kitteh.create(:name => 'Ugly Kitteh')

# support default values:
puts cute_one.configuration.be_cute?   # => true
puts cute_one.configuration[:be_cute]  # => true
puts cute_one.configuration[:cheezburger_limit] # => 10

# provides convenient configuration writers:
ugly_one.configuration[:be_cute] = false
ugly_one.configuration[:cheezburger_limit] = 100

puts ugly_one.configuration.be_cute? # => false
puts ugly_one.configuration[:cheezburger_limit] # => 100

# or with a bulk assignment:
ugly_one.configuration = {
  :be_cute => true,
  :cheezburger_limit => 10
}

puts ugly_one.configuration.be_cute? # => true
puts ugly_one.configuration[:cheezburger_limit] # => 10
Something went wrong with that request. Please try again.