Sha256: 67e2e46fb42ddbdce00feb578cc9b378d2e6b58ce6bcc7a787e3daee3c12be2a
Contents?: true
Size: 706 Bytes
Versions: 1
Compression:
Stored size: 706 Bytes
Contents
# Needed for extract_options! method. require 'active_support' # +FormObject+ module. # # Depends on Virtus for model attributes. # Assigns attributes to parent model. # ex: # form_attributes :field1, field2, ..., :model => Integer # Same syntax as Rails validations module Virtus module Extras module FormObject def form_attributes(*args) options = args.extract_options! model = options[:model] attributes = args attributes.each do |attribute_key| attribute attribute_key, model, optional_args(options) end end private def optional_args(options) options.tap { |hs| hs.delete(:model) } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
virtus-extras-0.1.0 | lib/Virtus/extras/form_object.rb |