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



192
193
194
195
196
197
198
199
# File 'lib/randumb/relation.rb', line 192

def method_missing(symbol, *args)
  if symbol.to_s =~ /^random_weighted_by_(\w+)$/
    ActiveSupport::Deprecation.warn "Dynamic finders will be removed in randumb 1.0 http://guides.rubyonrails.org/active_record_querying.html#dynamic-finders"
    random_weighted($1, *args)
  else
    super
  end
end

Instance Method Details

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

Returns:

  • (Boolean)


201
202
203
204
205
206
207
208
# File 'lib/randumb/relation.rb', line 201

def respond_to?(symbol, include_private=false)
  if symbol.to_s =~ /^random_weighted_by_(\w+)$/
    ActiveSupport::Deprecation.warn "Dynamic finders will be removed in randumb 1.0 http://guides.rubyonrails.org/active_record_querying.html#dynamic-finders"
    true
  else
    super
  end
end