forked from completelynovel/amazon-product-advertising-api
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support core extensions were clashing with Rails's so namespaced them.
- Loading branch information
Jon Gilbraith
committed
Jun 11, 2009
1 parent
6d65ad8
commit 1d26b8f
Showing
1 changed file
with
51 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
class Class | ||
def cattr_reader(sym) | ||
class_eval(<<-EOS, __FILE__, __LINE__) | ||
unless defined? @@#{sym} # unless defined? @@hair_colors | ||
@@#{sym} = nil # @@hair_colors = nil | ||
end # end | ||
# | ||
def self.#{sym} # def self.hair_colors | ||
@@#{sym} # @@hair_colors | ||
end # end | ||
# | ||
def #{sym} # def hair_colors | ||
@@#{sym} # @@hair_colors | ||
end # end | ||
EOS | ||
end | ||
module AmazonProductAdvertisingApi | ||
|
||
class Class | ||
def cattr_reader(sym) | ||
class_eval(<<-EOS, __FILE__, __LINE__) | ||
unless defined? @@#{sym} # unless defined? @@hair_colors | ||
@@#{sym} = nil # @@hair_colors = nil | ||
end # end | ||
# | ||
def self.#{sym} # def self.hair_colors | ||
@@#{sym} # @@hair_colors | ||
end # end | ||
# | ||
def #{sym} # def hair_colors | ||
@@#{sym} # @@hair_colors | ||
end # end | ||
EOS | ||
end | ||
|
||
def cattr_writer(sym) | ||
class_eval(<<-EOS, __FILE__, __LINE__) | ||
unless defined? @@#{sym} # unless defined? @@hair_colors | ||
@@#{sym} = nil # @@hair_colors = nil | ||
end # end | ||
# | ||
def self.#{sym}=(obj) # def self.hair_colors=(obj) | ||
@@#{sym} = obj # @@hair_colors = obj | ||
end # end | ||
EOS | ||
end | ||
def cattr_writer(sym) | ||
class_eval(<<-EOS, __FILE__, __LINE__) | ||
unless defined? @@#{sym} # unless defined? @@hair_colors | ||
@@#{sym} = nil # @@hair_colors = nil | ||
end # end | ||
# | ||
def self.#{sym}=(obj) # def self.hair_colors=(obj) | ||
@@#{sym} = obj # @@hair_colors = obj | ||
end # end | ||
EOS | ||
end | ||
|
||
def cattr_accessor(sym) | ||
cattr_reader(sym) | ||
cattr_writer(sym) | ||
end | ||
|
||
def cattr_accessor(sym) | ||
cattr_reader(sym) | ||
cattr_writer(sym) | ||
end | ||
|
||
end | ||
|
||
class String | ||
class String | ||
|
||
def camelize(first_letter_in_uppercase = true) | ||
if first_letter_in_uppercase | ||
self.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } | ||
else | ||
self.first + camelize(self)[1..-1] | ||
def camelize(first_letter_in_uppercase = true) | ||
if first_letter_in_uppercase | ||
self.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase } | ||
else | ||
self.first + camelize(self)[1..-1] | ||
end | ||
end | ||
end | ||
|
||
def underscore | ||
self.to_s.gsub(/::/, '/'). | ||
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). | ||
gsub(/([a-z\d])([A-Z])/,'\1_\2'). | ||
tr("-", "_"). | ||
downcase | ||
end | ||
|
||
def underscore | ||
self.to_s.gsub(/::/, '/'). | ||
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). | ||
gsub(/([a-z\d])([A-Z])/,'\1_\2'). | ||
tr("-", "_"). | ||
downcase | ||
end | ||
|
||
end | ||
|
||
end |