Git Product home page Git Product logo

Comments (7)

nathanl avatar nathanl commented on September 26, 2024

For consistency, you might consider moving away from the format_first_name style and making a format_column that mirrors format_header. For example, the user could do:

def format_column(column_name, value)
   case column_name.to_sym
   when :month, :location then value.capitalize
   when :weaksauce_secret then Base64.encode64(value)
   else formatter.number_to_currency(value)
   end
end

from dossier.

adamhunter avatar adamhunter commented on September 26, 2024

In some reports I've been moving the other way and doing a first_name_header method and using format_header as a dispatcher.

from dossier.

adamhunter avatar adamhunter commented on September 26, 2024

Though it would be nice to do

def format_column(name, value)
  case name.to_sym
  when :amount, :tax, :subtotal
    formatter.number_to_currency(value)
  else
    value
  end
end

One important thing to remember is that a default formatter like this would need to always return a value...

from dossier.

nathanl avatar nathanl commented on September 26, 2024

One important thing to remember is that a default formatter like this would need to always return a value...

True. It would be helpful to raise an exception if it didn't.

from dossier.

adamhunter avatar adamhunter commented on September 26, 2024

The problem with that, is that sometimes you might not want it to return a value intentionally.

Sent from my iPhone

On Jun 14, 2013, at 1:48 PM, Nathan Long [email protected] wrote:

One important thing to remember is that a default formatter like this would need to always return a value...

True. It would be helpful to raise an exception if it didn't.


Reply to this email directly or view it on GitHub.

from dossier.

nathanl avatar nathanl commented on September 26, 2024

Because you want the column to be blank? In that case, you could return an empty string; the exception would be raised if you returned nil.

from dossier.

adamhunter avatar adamhunter commented on September 26, 2024

Good point, returning nil should raise an exception.

from dossier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.