Project

coati

0.0
No commit activity in last 3 years
No release in over 3 years
A simple utility that hides instance variables inside Ruby objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

Coati

Description

Coati hides user-defined instance variables from being show when inspecting an instance of the class.

Imagine you have a simple class like:

class TestClass
  def initialize(username, password)
    @username = username
    @password = password
  end
end

Then when you inspect the instance of the class, the output will be something like:

[1] pry(main)> instance = TestClass.new('Joe', 'supersecretpassword')
=> #<TestClass:0x007f9633ca87f0 @username="Joe", @password="supersecretpassword">

...even if we don't want the password value to be shown. This gem addresses this problem.

This gem is named after an American mammal.

Installation

Simply do

gem install coati

Usage

Firstly require it from the file:

require 'coati'

Then use the attr_hider method in the class:

class TestClass
  attr_hider :password

  def initialize(username, password)
    @username = username
    @password = password
  end
end

When inspecting an instance of the class, the ouput will be something like:

[1] pry(main)> instance = TestClass.new('Joe', 'supersecretpassword')
=> #<TestClass:0x007f9633ca87f0 @username="Joe">