Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Object#acts_like? and Time#acts_like_time? and Date#acts_like_dat…
…e? to facilitate duck-typing git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5951 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
8 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
require 'date' | ||
require File.dirname(__FILE__) + '/date/behavior' | ||
require File.dirname(__FILE__) + '/date/calculations' | ||
require File.dirname(__FILE__) + '/date/conversions' | ||
|
||
class Date#:nodoc: | ||
include ActiveSupport::CoreExtensions::Date::Behavior | ||
include ActiveSupport::CoreExtensions::Date::Calculations | ||
include ActiveSupport::CoreExtensions::Date::Conversions | ||
end |
13 changes: 13 additions & 0 deletions
13
activesupport/lib/active_support/core_ext/date/behavior.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module ActiveSupport #:nodoc: | ||
module CoreExtensions #:nodoc: | ||
module Date #:nodoc: | ||
module Behavior | ||
# Enable more predictable duck-typing on Date-like classes. See | ||
# Object#acts_like?. | ||
def acts_like_date? | ||
true | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "#{File.dirname(__FILE__)}/time/behavior" | ||
|
||
class DateTime | ||
include ActiveSupport::CoreExtensions::Time::Behavior | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
require File.dirname(__FILE__) + '/time/behavior' | ||
require File.dirname(__FILE__) + '/time/calculations' | ||
require File.dirname(__FILE__) + '/time/conversions' | ||
|
||
class Time#:nodoc: | ||
include ActiveSupport::CoreExtensions::Time::Behavior | ||
include ActiveSupport::CoreExtensions::Time::Calculations | ||
include ActiveSupport::CoreExtensions::Time::Conversions | ||
end |
13 changes: 13 additions & 0 deletions
13
activesupport/lib/active_support/core_ext/time/behavior.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module ActiveSupport #:nodoc: | ||
module CoreExtensions #:nodoc: | ||
module Time #:nodoc: | ||
module Behavior | ||
# Enable more predictable duck-typing on Time-like classes. See | ||
# Object#acts_like?. | ||
def acts_like_time? | ||
true | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters