Module: Mongoid::DynamicMatchers::Finder

Included in:
FindBy
Defined in:
lib/mongoid/dynamic_matchers.rb

Instance Method Summary collapse

Instance Method Details

#attributes_hashObject



88
89
90
# File 'lib/mongoid/dynamic_matchers.rb', line 88

def attributes_hash
  "{" + attribute_names.map { |name| ":#{name} => #{name}" }.join(',') + "}"
end

#bodyObject



76
77
78
# File 'lib/mongoid/dynamic_matchers.rb', line 76

def body
  result
end

#finderObject

Raises:

  • (NotImplementedError)


92
93
94
# File 'lib/mongoid/dynamic_matchers.rb', line 92

def finder
  raise NotImplementedError
end

#resultObject



80
81
82
# File 'lib/mongoid/dynamic_matchers.rb', line 80

def result
  "#{finder}(#{attributes_hash}).first"
end

#signatureObject



84
85
86
# File 'lib/mongoid/dynamic_matchers.rb', line 84

def signature
  attribute_names.join(', ')
end