Sha256: 6b2a0807c9aabcd215a470965fe7c1caa8902b7bdcfacbf5847009a33715a4d1
Contents?: true
Size: 997 Bytes
Versions: 5
Compression:
Stored size: 997 Bytes
Contents
module Recurly module Helper def camelize underscored_word underscored_word.to_s.gsub(/(?:^|_)(.)/) { $1.upcase } end def classify table_name camelize singularize(table_name.to_s.sub(/.*\./, '')) end def demodulize class_name_in_module class_name_in_module.to_s.sub(/^.*::/, '') end def pluralize word word.to_s.sub(/([^s])$/, '\1s') end def singularize word word.to_s.sub(/s$/, '').sub(/ie$/, 'y') end def underscore camel_cased_word word = camel_cased_word.to_s.dup word.gsub!(/::/, '/') word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr! "-", "_" word.downcase! word end def hash_with_indifferent_read_access base = {} indifferent = Hash.new { |hash, key| hash[key.to_s] if key.is_a? Symbol } base.each_pair { |key, value| indifferent[key.to_s] = value } indifferent end extend self end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
recurly-2.0.14 | lib/recurly/helper.rb |
recurly-2.0.13 | lib/recurly/helper.rb |
recurly-2.0.12 | lib/recurly/helper.rb |
recurly-2.0.11 | lib/recurly/helper.rb |
recurly-2.0.10 | lib/recurly/helper.rb |