Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set multiple attributes #327

Closed
michaelachrisco opened this issue Jul 28, 2015 · 1 comment
Closed

Set multiple attributes #327

michaelachrisco opened this issue Jul 28, 2015 · 1 comment

Comments

@michaelachrisco
Copy link

Right now, I use my own very small custom gem called virtus-extras to create multiple like attributes within my form objects like so:

require 'active_model'
require 'active_support'
require 'virtus/extras'

class UserEntry
  include Virtus.model

  extend ActiveModel::Naming
  include ActiveModel::Conversion
  extend Virtus::Extras::FormObject

  form_attributes :first_name,
                  :last_name,
                  :display_name,
                  :model => String

  form_attributes :is_active,
                  :model => Integer

  form_attributes :hidden,
                  :model => Integer,
                  :writer => :private
end

The meat and potatoes are here: https://github.com/michaelachrisco/virtus-extras/blob/master/lib/virtus/extras/form_object.rb

I was wondering if this kind of implementation would be welcome within the main gem? I understand this is more of a personal preference (given that the syntax is more akin to ruby validation).

Thoughts and opinions? Also apologies if there is already some method that does this.

@michaelachrisco
Copy link
Author

Gem takes care of this format. Closing.,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant