class ActiveRecord::DynamicMatchers::Method
Public class methods
Source code GitHub
# File activerecord/lib/active_record/dynamic_matchers.rb, line 38
def define(model, name)
model.class_eval <<-CODE, __FILE__, __LINE__ + 1
def self.#{name}(#{signature(model, name)})
#{body(model, name)}
end
CODE
end
Source code GitHub
# File activerecord/lib/active_record/dynamic_matchers.rb, line 30
def match(name)
FindBy.match?(name) || FindByBang.match?(name)
end
Source code GitHub
# File activerecord/lib/active_record/dynamic_matchers.rb, line 34
def valid?(model, name)
attribute_names(model, name.to_s).all? { |name| model.columns_hash[name] || model.reflect_on_aggregation(name.to_sym) }
end