Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 maskable_attribute.gemspec
README.md

Maskable Attribute

maskable_attribute is an ActiveRecord extension that allows for 'masking' a records' attribute. It provides the ability to have an objects' attribute be dynamically assigned at a given point in time while providing the capability to make a one-location change that propagates through all resulting objects containing the resulting attribute mask.

Install

Via rubygems:

gem install maskable_attribute

Via bundler:

Add the following line to Gemfile:

gem 'maskable_attribute'

Then, run bundler:

bundle install

Usage

To use the maskable_attribute gem, simply create corresponding maskable_attribute attributes in the ActiveRecord model that you wish to affect.

For example, the following User class has a maskable attribute of :foo that can contain values of :bar, :baz and :qux

class User < ActiveRecord::Base
  maskable_attribute :foo, [ :bar, :baz ]
end

Creating a user with the above mask can be performed via the following:

user = User.new :bar => "a", :baz => "b", :foo => "{bar}-{baz}"

Now that the user object is created, there are several accessor methods to return different variations of the attribute:

user.masks              # { :foo => { :bar, :baz } }
user.foo.masks          # [ :bar, :baz ]
user.foo                # "a-b"
user.foo.unmasked       # "{bar}-{baz}"

Supported Ruby versions

Maskable Attribute supports Ruby 1.9.x+

Additional Information

Contributing

Contributions to the code-base are welcomed and handled via the normal Github pull request process.

Owner

maskable_attribute is written and maintained by Bill Transue

Something went wrong with that request. Please try again.