Module: Nandi::Formatting::ClassMethods

Defined in:
lib/nandi/formatting.rb

Instance Method Summary collapse

Instance Method Details

#formatted_property(name) ⇒ Object

Define an accessor method that will retrieve a value from a cell’s model and format it with the format_value method below.

Examples:

formatting the foo property

class MyCell < Cells::ViewModel
  include Nandi::Formatting

  formatted_property :foo
end

Parameters:

  • name (String)

    the attribute on model to retrieve



18
19
20
21
22
# File 'lib/nandi/formatting.rb', line 18

def formatted_property(name)
  define_method(name) do
    format_value(model.send(name))
  end
end