Sha256: d9b2699473fe959e3c59f98ca16a70da94d2eabb6e165828bf1efcc9e4ea1c46

Contents?: true

Size: 664 Bytes

Versions: 8

Compression:

Stored size: 664 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 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

8 entries across 8 versions & 1 rubygems

Version Path
fog-core-1.29.0 lib/fog/core/attributes/time.rb
fog-core-1.28.0 lib/fog/core/attributes/time.rb
fog-core-1.27.4 lib/fog/core/attributes/time.rb
fog-core-1.27.3 lib/fog/core/attributes/time.rb
fog-core-1.27.2 lib/fog/core/attributes/time.rb
fog-core-1.27.1 lib/fog/core/attributes/time.rb
fog-core-1.27.0 lib/fog/core/attributes/time.rb
fog-core-1.25.0 lib/fog/core/attributes/time.rb