Module: Cell::ViewModel::Escaped::Property

Defined in:
lib/cell/escaped.rb

Instance Method Summary collapse

Instance Method Details

#property(name, *args) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cell/escaped.rb', line 7

def property(name, *args)
  super.tap do # super defines #title
    mod = Module.new do
      define_method(name) do |options={}|
        value = super() # call the original #title.
        return value unless value.is_a?(String)
        return value if options[:escape] == false
        escape!(value)
      end
    end
    include mod
  end
end