Class: Mongoid::Matchers::Document::DocumentModuleMatcher
- Inherits:
-
Object
- Object
- Mongoid::Matchers::Document::DocumentModuleMatcher
- Includes:
- Helpers
- Defined in:
- lib/matchers/document/document.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(mod) ⇒ DocumentModuleMatcher
constructor
A new instance of DocumentModuleMatcher.
- #matches?(subject) ⇒ Boolean
Methods included from Helpers
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
#description ⇒ Object
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
16 17 18 |
# File 'lib/matchers/document/document.rb', line 16 def matches?(subject) class_of(subject).included_modules.include?(@mod) end |