Sha256: bd2b63cf2837aa87a9ed3e0c361980ace3bec009da5628c31ebf8fa86749293b

Contents?: true

Size: 912 Bytes

Versions: 87

Compression:

Stored size: 912 Bytes

Contents

module ActiveFedora
  module Attributes
    module Serializers
      ## 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
      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

      # set a hash of attributes on the object
      # @param [Hash] params the properties to set on the object
      def attributes=(params)
        super(deserialize_dates_from_form(params))
      end
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
active-fedora-10.1.0 lib/active_fedora/attributes/serializers.rb
active-fedora-10.1.0.rc1 lib/active_fedora/attributes/serializers.rb
active-fedora-9.7.2 lib/active_fedora/attributes/serializers.rb
active-fedora-10.0.0 lib/active_fedora/attributes/serializers.rb
active-fedora-10.0.0.beta4 lib/active_fedora/attributes/serializers.rb
active-fedora-10.0.0.beta3 lib/active_fedora/attributes/serializers.rb
active-fedora-10.0.0.beta2 lib/active_fedora/attributes/serializers.rb
active-fedora-10.0.0.beta1 lib/active_fedora/attributes/serializers.rb
active-fedora-9.13.0 lib/active_fedora/attributes/serializers.rb
active-fedora-9.12.0 lib/active_fedora/attributes/serializers.rb
active-fedora-9.11.0 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.4 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.3 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.2 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.1 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.0 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.0.pre2 lib/active_fedora/attributes/serializers.rb
active-fedora-9.10.0.pre1 lib/active_fedora/attributes/serializers.rb
active-fedora-9.9.1 lib/active_fedora/attributes/serializers.rb
active-fedora-9.9.0 lib/active_fedora/attributes/serializers.rb