Add model support for POROs to Rails core? (like ActiveAttr or Virtus)

18 views
Skip to first unread message

shi...@kkvesper.jp

unread,
Jul 19, 2014, 2:27:22 AM7/19/14
to rubyonra...@googlegroups.com
I imagine this has been brought up before, but I'd really like Rails core to add a library which allows plain old Ruby objects (POROs) to be treated as models, such as ActiveAttr (https://github.com/cgriego/active_attr) or Virtus (https://github.com/solnic/virtus).

ActiveModel comes close to doing this, but there are quite a few gaps such as the ability to define attributes on models, e.g.:

class Person
  include ActiveAttr::Attributes

  attribute :first_name, default: "Bob"
  attribute :last_name, type: String     # type-casting
end

The main advantage I see in doing this is that developers no longer need to rely on a third-party library which may diverge from Rails standards. Moreover, there may be opportunity to consolidate functionality common to Mongoid and ActiveRecord in this library.

Thoughts?

Reply all
Reply to author
Forward
0 new messages