forked from aviator/aviator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change completely does away with string monkeypatching to avoid any conflicts with ActiveSupport or other libraries that do the same monkeypatching logic. We also completely avoid using ActiveSupport since there may be clients that do not wish to include said gem into their environment.
- Loading branch information
1 parent
3c03504
commit 75c2f12
Showing
12 changed files
with
58 additions
and
53 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
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,24 +1,26 @@ | ||
class String | ||
module Aviator | ||
|
||
unless instance_methods.include? 'camelize' | ||
define_method :camelize do | ||
word = self.slice(0,1).capitalize + self.slice(1..-1) | ||
word.gsub(/_([a-zA-Z\d])/) { "#{$1.capitalize}" } | ||
end | ||
end | ||
class StrUtil | ||
|
||
class <<self | ||
|
||
unless instance_methods.include? 'constantize' | ||
define_method :constantize do | ||
self.split("::").inject(Object) do |namespace, sym| | ||
namespace.const_get(sym.to_s.camelize, false) | ||
def camelize(str) | ||
word = str.slice(0,1).capitalize + str.slice(1..-1) | ||
word.gsub(/_([a-zA-Z\d])/) { "#{$1.capitalize}" } | ||
end | ||
|
||
def constantize(str) | ||
str.split("::").inject(Object) do |namespace, sym| | ||
namespace.const_get(self.camelize(sym.to_s), false) | ||
end | ||
end | ||
|
||
def underscore(str) | ||
str.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase | ||
end | ||
end | ||
end | ||
|
||
unless instance_methods.include? 'underscore' | ||
define_method :underscore do | ||
self.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase | ||
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
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
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
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
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