Sha256: 48f6fa2c7fdd803329b815c847659aa2351a786398d640aeb5c929f9ea4dae79

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

= settings-goo

settings-goo is a simple ActiveRecord based model for storing global application settings for your rails application in your database.  Settings was designed to be as simple as possible and to mimic a Hash.  Data is stored in the database fields :key and :value.  The :value field is serialized as json.  The possible method_missing magic (ex: Settings.admin_email) was intentionally left off.  Keep it simple!  You can store any kind of data as your value, i.e. boolean, float, integer, array.  

== Installation

Install the settings-goo gem
  sudo gem install settings-goo

== Setup

Create the settings migration
  script/generate settings_migration

Run the database migration
  rake db:migrate

== Usage

Create some settings:
  Settings[:admin_email] = 'admin@somewhere.com'
  Settings[:role_enabled] = true
  Settings[:per_page] = 1
  Settings[:ca_tax] = 0.87

Retrieve some settings:
  Settings[:admin_email]    # returns 'admin@somewhere.com'
  Settings[:role_enabled]   # returns true
  Settings[:per_page]       # returns 1
  Settings[:ca_tax]         # return 0.87

Update a setting:
  Settings[:admin_email] = 'admin@somewhere.com'
  Settings[:admin_email] = 'another.admin@somewhere.com'
  Settings[:admin_email]    # returns 'another.admin@somewhere.com'
  
Remove a setting:
  Settings.remove(:admin_email)
  Settings[:admin_email]    # returns nil
  
List all setting keys:
  Settings.keys             # returns [:admin_email, :ca_tax, :per_page, :role_enabled]
  
== TODO

  Cache Settings.keys
  Cache Create rails plugin gem

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
settings-goo-0.1.0 README.rdoc