Sha256: 08bb938bd5df75cfb40f23f7be692d3bae4d65d3c25c99fb507536921a2c153b

Contents?: true

Size: 931 Bytes

Versions: 35

Compression:

Stored size: 931 Bytes

Contents

module ActiveFedora
  module Attributes
    module Serializers

      ## This allows you to use date_select helpers in rails views 
      # @param [Hash] parms 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| 
          if data = key.to_s.match(/^(.+)\((\d)i\)$/)
            dates[data[1]] ||= {}
            dates[data[1]][data[2]] = value
            params.delete(key)
          end
        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

35 entries across 35 versions & 1 rubygems

Version Path
active-fedora-5.7.1 lib/active_fedora/attributes/serializers.rb
active-fedora-5.7.0 lib/active_fedora/attributes/serializers.rb
active-fedora-5.6.3 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.rc1 lib/active_fedora/attributes/serializers.rb
active-fedora-5.6.2 lib/active_fedora/attributes/serializers.rb
active-fedora-5.6.1 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre10 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre9 lib/active_fedora/attributes/serializers.rb
active-fedora-5.6.0 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre8 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre7 lib/active_fedora/attributes/serializers.rb
active-fedora-5.5.2 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre6 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre5 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre4 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre3 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre2 lib/active_fedora/attributes/serializers.rb
active-fedora-5.5.1 lib/active_fedora/attributes/serializers.rb
active-fedora-6.0.0.pre1 lib/active_fedora/attributes/serializers.rb
active-fedora-5.5.0 lib/active_fedora/attributes/serializers.rb