Class: Mongoid::Matchers::Document::DocumentModuleMatcher

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/matchers/document/document.rb

Instance Method Summary collapse

Methods included from Helpers

#class_of, #to_sentence

Constructor Details

#initialize(mod) ⇒ DocumentModuleMatcher

Returns a new instance of DocumentModuleMatcher.



12
13
14
# File 'lib/matchers/document/document.rb', line 12

def initialize(mod)
  @mod = mod
end

Instance Method Details

#descriptionObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/matchers/document/document.rb', line 20

def description
  msg = case
        when @mod == DOCUMENT   then ''
        when @mod == PARANOIA   then 'paranoid '
        when @mod == VERSIONING then 'versioned '
        when @mod == TIMESTAMPS then 'timestamped '
        else raise "Unknow Mongoid module #{@mod}"
        end

  "be a #{msg}Mongoid document"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/matchers/document/document.rb', line 16

def matches?(subject)
  class_of(subject).included_modules.include?(@mod)
end