Module: Consort::Mongoid::ClassMethods

Defined in:
lib/consort/mongoid.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to_active_record(klass) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/consort/mongoid.rb', line 28

def belongs_to_active_record(klass)
  class_eval "    def \#{klass}\n      \#{klass.to_s.classify}.where(id: \#{klass.to_s.foreign_key})\n    end\n  CODE\nend\n"

#has_many_active_record(klass) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/consort/mongoid.rb', line 14

def has_many_active_record(klass)
  class_eval "    def \#{klass}\n      \#{klass.to_s.classify}.where(\#{name.foreign_key}: id)\n    end\n  CODE\nend\n"

#has_many_active_records(klass) ⇒ Object

DEPRECATED. Will be removed in 1.0.0.



23
24
25
26
# File 'lib/consort/mongoid.rb', line 23

def has_many_active_records(klass)
  ActiveSupport::Deprecation.warn 'Please use the singular has_many_active_record instead.'
  has_many_active_record(klass)
end

#has_one_active_record(klass) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/consort/mongoid.rb', line 6

def has_one_active_record(klass)
  class_eval "    def \#{klass}\n      \#{klass.to_s.classify}.where(\#{name.foreign_key}: id)\n    end\n  CODE\nend\n"

#mongoid_consorts_with_active_record?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/consort/mongoid.rb', line 36

def mongoid_consorts_with_active_record?
  true
end