1+ require 'zendesk_api/helpers'
2+
13module ZendeskAPI
24 # Represents an association between two resources
35 class Association
@@ -50,7 +52,7 @@ def generate_path(*args)
5052
5153 def side_load ( resources , side_loads )
5254 key = "#{ options . name } _id"
53- plural_key = "#{ options . name . to_s . singular } _ids"
55+ plural_key = "#{ Inflection . singular options . name . to_s } _ids"
5456
5557 resources . each do |resource |
5658 if resource . key? ( plural_key ) # Grab associations from child_ids field on resource
@@ -230,7 +232,7 @@ def has(resource_name, class_level_options = {})
230232 # @param [Symbol] resource The underlying resource name
231233 # @param [Hash] opts The options to pass to the method definition.
232234 def has_many ( resource_name , class_level_opts = { } )
233- klass = get_class ( class_level_opts . delete ( :class ) ) || get_class ( resource_name . to_s . singular )
235+ klass = get_class ( class_level_opts . delete ( :class ) ) || get_class ( Inflection . singular ( resource_name . to_s ) )
234236
235237 class_level_association = {
236238 :class => klass ,
@@ -259,7 +261,7 @@ def has_many(resource_name, class_level_opts = {})
259261
260262 # find and cache association
261263 instance_association = Association . new ( class_level_association . merge ( :parent => self ) )
262- singular_resource_name = resource_name . to_s . singular
264+ singular_resource_name = Inflection . singular ( resource_name . to_s )
263265
264266 resources = if ( ids = method_missing ( "#{ singular_resource_name } _ids" ) ) && ids . any?
265267 ids . map do |id |
@@ -296,7 +298,7 @@ def has_many(resource_name, class_level_opts = {})
296298 # reopened under a different superclass, an error will be thrown
297299 def get_class ( resource )
298300 return false if resource . nil?
299- res = resource . to_s . modulize
301+ res = ZendeskAPI :: Helpers . modulize_string ( resource . to_s )
300302
301303 begin
302304 const_get ( res )
@@ -318,7 +320,7 @@ def const_missing(*args)
318320 # reopened under a different superclass, an error will be thrown
319321 def get_class ( resource )
320322 return false if resource . nil?
321- res = resource . to_s . modulize . split ( "::" )
323+ res = ZendeskAPI :: Helpers . modulize_string ( resource . to_s ) . split ( "::" )
322324
323325 begin
324326 res [ 1 ..-1 ] . inject ( ZendeskAPI . const_get ( res [ 0 ] ) ) do |iter , k |
0 commit comments