rails_view_helpers 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,22 @@
1
1
  class NilClass
2
2
 
3
+ alias_method :original_to_s, :to_s
4
+
3
5
  # This hack enables us to call +to_s+ on a (supposedly) Date/Datetime
4
6
  # with out worrying that the value may be +nil+.
5
7
  #
6
8
  # @return [String]
7
9
  def to_s(*args)
8
- return super unless args.length == 1
9
-
10
- format = args.first
11
- return super unless known_formats.include?(format)
12
-
13
- return ''
10
+ if known_formats.include?(args.first)
11
+ ''
12
+ else
13
+ original_to_s(*args)
14
+ end
14
15
  end
15
16
 
16
17
  private
17
18
 
18
19
  def known_formats
19
- @known_formats ||= Date::DATE_FORMATS + Time::DATE_FORMATS
20
+ @known_formats ||= Date::DATE_FORMATS.keys + Time::DATE_FORMATS.keys
20
21
  end
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module RailsViewHelpers
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_view_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -265,7 +265,7 @@ files:
265
265
  - config/routes.rb
266
266
  - lib/generators/rails_view_helpers/install_generator.rb
267
267
  - lib/generators/rails_view_helpers/templates/app/assets/stylesheets/rails_view_helpers.css
268
- - lib/generators/rails_view_helpers/templates/config/initializers/local/core-extensions/nil_class.rb
268
+ - lib/generators/rails_view_helpers/templates/config/initializers/local/core-extensions/nil_class/datetime_to_s.rb
269
269
  - lib/rails_view_helpers/engine.rb
270
270
  - lib/rails_view_helpers/version.rb
271
271
  - lib/rails_view_helpers.rb