solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 229 forks source link

Use private method to set defaults. #159

Closed mattiassvedhem closed 11 years ago

mattiassvedhem commented 11 years ago

When pointing the default to a private method (which I guess is pretty common) it sets the default to the symbol instead.

class SomeObject
  include Virtus
  # default from a method name as symbol
  attribute :editor_title, String,  :default => :default_editor_title

  private
  def default_editor_title
    published? ? title : "UNPUBLISHED: #{title}"
  end
end
o = SomeObject.new
o.editor_title
# => :default_editor_title
solnic commented 11 years ago

It's already fixed in master (upcoming 1.0.0.beta1)