Module: Mascherari::AttrMasked

Defined in:
lib/mascherari/attr_masked.rb

Instance Method Summary collapse

Instance Method Details

#attr_masked(*attrs, options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mascherari/attr_masked.rb', line 3

def attr_masked(*attrs, options)
  attrs.each do |attr|
    class_eval %{
      def #{attr}_format
        @#{attr}_format ||= Formatter.new(#{options})
      end

      def #{attr}_masked
        #{attr}_format.mask #{attr}
      end

      def #{attr}_unmasked
        #{attr}_format.unmask #{attr}
      end
    }
  end
end