module MSS::Core::Inflection
@api private
Public Class Methods
class_name(name)
click to toggle source
# File lib/mss/core/inflection.rb, line 47 def class_name(name) name.sub(/^(.)/) { |m| m.upcase }. gsub(/[-_]([a-z])/i) { |m| m[1,1].upcase } end
ruby_name(mss_name)
click to toggle source
# File lib/mss/core/inflection.rb, line 19 def ruby_name mss_name inflector = Hash.new do |hash,key| key. sub(/^.*:/, ''). # strip namespace gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split words join('_').downcase # join parts end # add a few irregular inflections inflector['ETag'] = 'etag' inflector['s3Bucket'] = 's3_bucket' inflector['s3Key'] = 's3_key' inflector['Ec2KeyName'] = 'ec2_key_name' inflector['Ec2SubnetId'] = 'ec2_subnet_id' inflector['Ec2VolumeId'] = 'ec2_volume_id' inflector['Ec2InstanceId'] = 'ec2_instance_id' inflector['ElastiCache'] = 'elasticache' inflector['NotificationARNs'] = 'notification_arns' inflector[mss_name] end
Private Instance Methods
class_name(name)
click to toggle source
# File lib/mss/core/inflection.rb, line 47 def class_name(name) name.sub(/^(.)/) { |m| m.upcase }. gsub(/[-_]([a-z])/i) { |m| m[1,1].upcase } end
ruby_name(mss_name)
click to toggle source
# File lib/mss/core/inflection.rb, line 19 def ruby_name mss_name inflector = Hash.new do |hash,key| key. sub(/^.*:/, ''). # strip namespace gsub(/([A-Z0-9]+)([A-Z][a-z])/, '\1_\2'). # split acronyms scan(/[a-z]+|\d+|[A-Z0-9]+[a-z]*/). # split words join('_').downcase # join parts end # add a few irregular inflections inflector['ETag'] = 'etag' inflector['s3Bucket'] = 's3_bucket' inflector['s3Key'] = 's3_key' inflector['Ec2KeyName'] = 'ec2_key_name' inflector['Ec2SubnetId'] = 'ec2_subnet_id' inflector['Ec2VolumeId'] = 'ec2_volume_id' inflector['Ec2InstanceId'] = 'ec2_instance_id' inflector['ElastiCache'] = 'elasticache' inflector['NotificationARNs'] = 'notification_arns' inflector[mss_name] end