Sha256: 943d18aed9fcbd71360ad0f3cc23df6f93d7480177b583da2a74bd84248a2413

Contents?: true

Size: 751 Bytes

Versions: 41

Compression:

Stored size: 751 Bytes

Contents

module Fog
  module Attributes
    # = Fog Time Attribute
    #
    # This class handles Time attributes from the providers,
    # converting values to Time objects
    class Time < Default
      def create_setter
        model.class_eval <<-EOS, __FILE__, __LINE__
            def #{name}=(new_#{name})
              attributes[:#{name}] = if new_#{name}.nil? || new_#{name} == "" || new_#{name}.is_a?(::Time)
                new_#{name}
              elsif ::String === new_#{name}
                ::Time.parse(new_#{name})
              elsif new_#{name}.respond_to?(:to_time)
                new_#{name}.to_time
              else
                ::Time.parse(new_#{name})
              end
            end
        EOS
      end
    end
  end
end

Version data entries

41 entries across 38 versions & 3 rubygems

Version Path
fog-core-1.30.0 lib/fog/core/attributes/time.rb