module ActiveFedora::Attributes::Serializers

Public Instance Methods

attributes=(params) click to toggle source

set a hash of attributes on the object @param [Hash] params the properties to set on the object

Calls superclass method
# File lib/active_fedora/attributes/serializers.rb, line 23
def attributes=(params)
  super(deserialize_dates_from_form(params))
end
deserialize_dates_from_form(params) click to toggle source
This allows you to use date_select helpers in rails views

@param [Hash] params parameters hash @return [Hash] a parameters list with the date select parameters replaced with dates

# File lib/active_fedora/attributes/serializers.rb, line 7
def deserialize_dates_from_form(params)
  dates = {}
  params.each do |key, value|
    next unless data = key.to_s.match(/^(.+)\((\d)i\)$/)
    dates[data[1]] ||= {}
    dates[data[1]][data[2]] = value
    params.delete(key)
  end
  dates.each do |key, value|
    params[key] = [value['1'], value['2'], value['3']].join('-')
  end
  params
end