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



160
161
162
163
164
165
166
# File 'lib/randumb/relation.rb', line 160

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)


168
169
170
171
172
173
174
# File 'lib/randumb/relation.rb', line 168

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