class Dropkiq::DropMethodNameClassifier

Attributes

drop_method[RW]

Public Class Methods

new(drop_method) click to toggle source
# File lib/dropkiq/drop_method_name_classifier.rb, line 5
def initialize(drop_method)
  self.drop_method = drop_method.to_s
end

Public Instance Methods

classify() click to toggle source
# File lib/dropkiq/drop_method_name_classifier.rb, line 9
def classify
  if numeric_type_match?
    Dropkiq::NUMERIC_TYPE
  elsif boolean_type_match?
    Dropkiq::BOOLEAN_TYPE
  elsif text_type_match?
    Dropkiq::TEXT_TYPE
  elsif string_type_match?
    Dropkiq::STRING_TYPE
  end
end

Private Instance Methods

boolean_type_match?() click to toggle source
# File lib/dropkiq/drop_method_name_classifier.rb, line 28
def boolean_type_match?
  drop_method.ends_with?("?") ||
    drop_method.ends_with?("_present") ||
    drop_method.ends_with?("_changed")
end
numeric_type_match?() click to toggle source
# File lib/dropkiq/drop_method_name_classifier.rb, line 23
def numeric_type_match?
  drop_method.ends_with?("_id") ||
    drop_method.ends_with?("_count")
end
string_type_match?() click to toggle source
# File lib/dropkiq/drop_method_name_classifier.rb, line 38
def string_type_match?
  drop_method.ends_with?("name") ||
    drop_method.ends_with?("password") ||
    drop_method.ends_with?("type") ||
    drop_method.ends_with?("title") ||
    drop_method.ends_with?("to_s") ||
    drop_method.ends_with?("to_string") ||
    drop_method.ends_with?("_url") ||
    drop_method.ends_with?("_email") ||
    drop_method.ends_with?("_partial") ||
    drop_method.ends_with?("_email_address") ||
    drop_method.ends_with?("_uuid")
end
text_type_match?() click to toggle source
# File lib/dropkiq/drop_method_name_classifier.rb, line 34
def text_type_match?
  drop_method.ends_with?("description")
end