Acts As Configurable plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://svn.nkryptic.com/plugins/acts_as_configurable
This mixin will provide your model with a large variety of configuration options.
class User < ActiveRecord::Base acts_as_configurable end
Example:
user = User.create(:name => 'joe') user.settings # => [] user.settings[:friends] = ['jane','sam','karl'] user.settings[:friends] # => ['jane','sam','karl'] user.settings[:age] = 25 user.settings[:age] # => 25
OR
user = User.create(:name => 'joe') post = Post.find(:first) user.settings_for(post) # => [] user.settings_for(post)[:show_headlines] = true user.settings_for(post)[:show_headlines] # => true user.settings_for(post).size # => 1 # but the user's untargeted settings are still empty user.settings # => [] user.settings.each_with_key {|k,s| do something} # k is the key (a string) and s is the setting user.settings_for(post).each_with_key {|k,s| do something} # k is the key (a string) and s is the setting
This mixin will provide your model with the ability to see where it is used as a target of acts_as_configurable
class Post < ActiveRecord::Base acts_as_configurable_target end
Example:
user = User.create(:name => 'joe') post = Post.find(:first) user.settings_for(post) # => [] user.settings_for(post)[:num_lines] = 15 user.settings_for(post)[:num_lines] # => 15 post.targeted_settings[:num_lines].size # => 1 post.targeted_settings[:num_lines].first # => 15 post.targeted_settings[:num_lines].first.owner # => user
OR
user = User.create(:name => 'joe') post = Post.find(:first) user.settings_for(post) # => [] user.settings_for(post)[:num_lines] = 15 user.settings_for(post)[:num_lines] # => 15 user.settings_for(post)[:hide_comments] # => true post.targeted_settings_for(user)[:num_lines] # => 15 post.targeted_settings_for(user) # => [15,true] post.targeted_settings_for(user).collect {|x| x.name} # => ['num_lines','hide_comments']
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: maxim_kulkin, about 1 year ago

