Class: Fog::Attributes::Time

Inherits:
Default
  • Object
show all
Defined in:
lib/fog/core/attributes/time.rb

Overview

Fog Time Attribute

This class handles Time attributes from the providers, converting values to Time objects

Instance Attribute Summary

Attributes inherited from Default

#aliases, #as, #default, #model, #name, #squash

Instance Method Summary collapse

Methods inherited from Default

#create_aliases, #create_getter, #create_mask, #initialize, #set_defaults

Constructor Details

This class inherits a constructor from Fog::Attributes::Default

Instance Method Details

#create_setterObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/core/attributes/time.rb', line 8

def create_setter
  model.class_eval "      def \#{name}=(new_\#{name})\n        attributes[:\#{name}] = if new_\#{name}.nil? || new_\#{name} == \"\" || new_\#{name}.is_a?(::Time)\n          new_\#{name}\n        elsif ::String === new_\#{name}\n          ::Time.parse(new_\#{name})\n        elsif new_\#{name}.respond_to?(:to_time)\n          new_\#{name}.to_time\n        else\n          ::Time.parse(new_\#{name})\n        end\n      end\n  EOS\nend\n", __FILE__, __LINE__