Skip to content
No description or website provided.
Ruby JavaScript
Find file

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.


Via rubygems:

gem install maskable_attribute

Via bundler:

Add the following line to Gemfile:

gem 'maskable_attribute'

Then, run bundler:

bundle install


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 ]

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

user = :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 } }          # [ :bar, :baz ]                # "a-b"       # "{bar}-{baz}"

Supported Ruby versions

Maskable Attribute supports Ruby 1.9.x+

Additional Information


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


maskable_attribute is written and maintained by Bill Transue

Something went wrong with that request. Please try again.