Callbacks + Traits?

16 views
Skip to first unread message

Andrew Arrigoni

unread,
Feb 7, 2012, 11:53:21 AM2/7/12
to factor...@googlegroups.com
Is it possible to do something akin to the following?

factory :people do
  name "John"

  after_create { |model| model.run_something_for_everyone

  trait :special do
    status :special
    after_create { |model| model.run_something_only_for_special_people }
  end

  trait :silly do
    status :silly
    after_create { |model| model.run_something_only_for_silly_people }
  end
end

If so, how? Is the above syntax correct? If not, are there alternatives to accomplish the same thing?
Reply all
Reply to author
Forward
0 new messages