Class: MockRelation
- Inherits:
-
Hash
show all
- Defined in:
- lib/mock_relation.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*mocked_scopes) ⇒ MockRelation
Returns a new instance of MockRelation.
4
5
6
7
|
# File 'lib/mock_relation.rb', line 4
def initialize(*mocked_scopes)
@mocked_scopes = mocked_scopes
super()
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(scope, *args) ⇒ Object
47
48
49
|
# File 'lib/mock_relation.rb', line 47
def method_missing(scope, *args)
mocks_scope?(scope) ? record_invocation(scope, *args) : super
end
|
Instance Attribute Details
#mocked_scopes ⇒ Object
Returns the value of attribute mocked_scopes.
2
3
4
|
# File 'lib/mock_relation.rb', line 2
def mocked_scopes
@mocked_scopes
end
|
Instance Method Details
#destroy_all ⇒ Object
27
28
29
|
# File 'lib/mock_relation.rb', line 27
def destroy_all
@destroyed = true
end
|
#destroyed? ⇒ Boolean
31
32
33
|
# File 'lib/mock_relation.rb', line 31
def destroyed?
@destroyed
end
|
#includes(*args) ⇒ Object
Also known as:
joins, scoped
17
18
19
|
# File 'lib/mock_relation.rb', line 17
def includes(*args)
self
end
|
#scoped? ⇒ Boolean
9
10
11
|
# File 'lib/mock_relation.rb', line 9
def scoped?
any?
end
|
#scoped_by?(scope, *args) ⇒ Boolean
13
14
15
|
# File 'lib/mock_relation.rb', line 13
def scoped_by?(scope, *args)
fetch(scope, []).include?(args)
end
|
#unscoped ⇒ Object
23
24
25
|
# File 'lib/mock_relation.rb', line 23
def unscoped
clone.clear
end
|