Read more

has_defaults 0.4.2 lets you use dagger lambdas

Henning Koch
May 08, 2015Software engineer at makandra GmbH

Starting with has_defaults 0.4.2, default values that are lambdas are no longer called with the current object as argument, but instance_exec'd instead.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

This means you can now use dagger lambdas like this:

has_defaults :full_name => -> { "#{first_name} #{last_name}" }

You can also use lambda and proc as long as you don't take parameters:

has_defaults :full_name => lambda { "#{first_name} #{last_name}" }
has_defaults :full_name => proc { "#{first_name} #{last_name}" }

You can no longer write this:

has_defaults :full_name => lambda { |person| "#{person.first_name} #{person.last_name}" }
Posted by Henning Koch to makandra dev (2015-05-08 17:17)