Module: Aqua::Pack::HiddenAttributes::ClassMethods

Defined in:
lib/aqua/object/pack.rb

Instance Method Summary collapse

Instance Method Details

#_hidden_attributesArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Reader method for accessing hidden attributes.

Returns:

  • (Array)

    containing strings representing instance variables



34
35
36
# File 'lib/aqua/object/pack.rb', line 34

def _hidden_attributes 
  @_hidden_attributes ||= []
end

#hide_attributes(*ivars) ⇒ Object

Used in class declaration to assign certain instance variables as not for persistance class User

include Aqua::Object
attr_accessor :username, :email, :password, :password_confirmation, :cryped_password, :salt
hide_attributes :password, :password_confirmation 
# ... lots more user code here ...

end In this case it is useful for omitting sensitive information while persisting the object, but maintaining the password and confirmation temporarily requires the use of instance variables.

Parameters:

  • or (Symbol)
    Array of Symbols

    ivars



50
51
52
53
54
55
# File 'lib/aqua/object/pack.rb', line 50

def hide_attributes( *ivars )
  ivars.each do |ivar|
    raise ArgumentError, '' unless ivar.class == Symbol
    _hidden_attributes << "@#{ivar}" unless _hidden_attributes.include?( "@#{ivar}" )
  end  
end