zoneless_time 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,28 @@ module ActiveRecord
2
2
  module ZonelessTimeSupport
3
3
  def zoneless_time(sym)
4
4
  instance_eval do
5
- self.composed_of sym, :class_name => 'ZonelessTime::TimeWithoutZone',
6
- :mapping => [[sym, 'time']], :constructor => :at
5
+ define_method sym do
6
+ t = instance_variable_get(:"@#{sym}")
7
+
8
+ if t.nil?
9
+ t = ZonelessTime::TimeWithoutZone.at(read_attribute(sym.to_s))
10
+ instance_variable_set(:"@#{sym}", t)
11
+ end
12
+
13
+ t
14
+ end
15
+
7
16
  self.skip_time_zone_conversion_for_attributes << sym
17
+
8
18
  define_method "#{sym}=" do |val|
9
19
  if val.is_a? ZonelessTime::TimeWithoutZone
10
20
  super val
11
21
  else
12
22
  super ZonelessTime::TimeWithoutZone.at(val)
13
23
  end
14
- send sym, true
24
+
25
+ instance_variable_set(:"@#{sym}", nil)
26
+ send sym
15
27
  end
16
28
  end
17
29
  end
@@ -1,3 +1,3 @@
1
1
  module ZonelessTime
2
- VERSION = "1.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoneless_time
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- version: "1.0"
9
+ - 1
10
+ version: 1.0.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Shaun Mangelsdorf
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2013-01-16 00:00:00 Z
18
+ date: 2013-06-06 00:00:00 Z
18
19
  dependencies: []
19
20
 
20
21
  description: TimeWithoutZone support for ActiveRecord
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  requirements: []
77
78
 
78
79
  rubyforge_project:
79
- rubygems_version: 1.8.24
80
+ rubygems_version: 1.8.25
80
81
  signing_key:
81
82
  specification_version: 3
82
83
  summary: TimeWithoutZone support for ActiveRecord