Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4ec100b

Browse files
committed
Support version checking in rails 3
1 parent df69abb commit 4ec100b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎elasticsearch-persistence/lib/elasticsearch/persistence/model/time_with_zone_typecaster.rb‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@ def call(value)
1919
precision = @precision_override
2020
elsif !ActiveSupport::JSON::Encoding.use_standard_json_time_format
2121
precision = 0
22-
elsif ActiveSupport.version < Gem::Version.new('4.0')
22+
elsif active_support_version < Gem::Version.new('4.0')
2323
precision = 0
24-
elsif ActiveSupport.version >= Gem::Version.new('4.0') &&
25-
ActiveSupport.version < Gem::Version.new('4.1')
24+
elsif active_support_version >= Gem::Version.new('4.0') &&
25+
active_support_version < Gem::Version.new('4.1')
2626
precision = 3
2727
else
2828
precision = ActiveSupport::JSON::Encoding.time_precision
2929
end
3030

3131
result.change(usec: (result.usec / (10**(6-precision))))
3232
end
33+
34+
def active_support_version
35+
if ActiveSupport.respond_to?(:version)
36+
ActiveSupport.version
37+
else
38+
Gem::Version.new(ActiveSupport::VERSION::STRING)
39+
end
40+
end
3341
end
3442
end
3543
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /