Method: DataMapper::Hook::ClassMethods#hook_method_name

Defined in:
lib/dm-core/support/hook.rb

#hook_method_name(target_method, prefix, suffix) ⇒ Object

Generates names for the various utility methods. We need to do this because the various utility methods should not end in = so, while we’re at it, we might as well get rid of all punctuation.



196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/dm-core/support/hook.rb', line 196

def hook_method_name(target_method, prefix, suffix)
  target_method = target_method.to_s

  case target_method[-1,1]
    when '?' then "#{prefix}_#{target_method[0..-2]}_ques_#{suffix}"
    when '!' then "#{prefix}_#{target_method[0..-2]}_bang_#{suffix}"
    when '=' then "#{prefix}_#{target_method[0..-2]}_eq_#{suffix}"
    # I add a _nan_ suffix here so that we don't ever encounter
    # any naming conflicts.
    else "#{prefix}_#{target_method[0..-1]}_nan_#{suffix}"
  end
end