Sha256: 4fa904a3d64c59fd65276241301aefbff51c704b2d64e4090fa24cd28ef87ef6
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
module Jack module String def self.included(klass) klass.class_eval do def camelize self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join end # Ruby 1.9 introduces an inherit argument for Module#const_get and # #const_defined? and changes their default behavior. # Taken from rails' inflectors. http://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflector/methods.rb if Module.method(:const_get).arity == 1 def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end else def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name) end constant end end end end end end String.send(:include, Jack::String)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jackb-0.0.3 | lib/jack/string.rb |