Module: Randumb::ActiveRecord::MethodMissingMagicks

Included in:
ActiveRecord::Base, ActiveRecord::Relation
Defined in:
lib/randumb/relation.rb

Overview

These get registered as class and instance methods

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/randumb/relation.rb', line 146

def method_missing(symbol, *args)
  if symbol.to_s =~ /^random_weighted_by_(\w+)$/
    random_weighted($1, *args)
  else
    super
  end
end

Instance Method Details

#respond_to?(symbol, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


154
155
156
157
158
159
160
# File 'lib/randumb/relation.rb', line 154

def respond_to?(symbol, include_private=false)
  if symbol.to_s =~ /^random_weighted_by_(\w+)$/
    true
  else
    super
  end
end