Deprecate composed of #6742

merged 1 commit into from Jun 18, 2012
Commits on Jun 18, 2012
  1. @steveklabnik

    Deprecating composed_of in ActiveRecord

    steveklabnik committed Jun 15, 2012
    This feature adds a lot of complication to ActiveRecord for dubious
    value. Let's talk about what it does currently:
    class Customer < ActiveRecord::Base
      composed_of :balance, :class_name => "Money", :mapping => %w(balance
    Instead, you can do something like this:
        def balance
          @balance ||=, currency)
        def balance=(balance)
          self[:value] = balance.value
          self[:currency] = balance.currency
          @balance = balance
    Since that's fairly easy code to write, and doesn't need anything
    extra from the framework, if you use composed_of today, you'll
    have to add accessors/mutators like that.
    This feature will be removed in Rails 4.