Class: DataMapper::Matchers::HaveManyThrough
- Inherits:
-
Object
- Object
- DataMapper::Matchers::HaveManyThrough
- Defined in:
- lib/dm/matchers/have_many_through.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(children, broker) ⇒ HaveManyThrough
constructor
A new instance of HaveManyThrough.
- #matches?(parent) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(children, broker) ⇒ HaveManyThrough
Returns a new instance of HaveManyThrough.
5 6 7 |
# File 'lib/dm/matchers/have_many_through.rb', line 5 def initialize(children, broker) @children, @broker = children, broker end |
Instance Method Details
#description ⇒ Object
26 27 28 |
# File 'lib/dm/matchers/have_many_through.rb', line 26 def description "has many #{@children} through #{@broker}" end |
#failure_message ⇒ Object
18 19 20 |
# File 'lib/dm/matchers/have_many_through.rb', line 18 def "expected to have many #{@children} through #{@broker}" end |
#matches?(parent) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/dm/matchers/have_many_through.rb', line 9 def matches?(parent) parent_class = parent.is_a?(Class) ? parent : parent.class relation = parent_class.relationships[@children.to_s] relation.parent_model == parent_class and relation.name == @children.to_sym and relation.[:through] == @broker.to_sym end |
#negative_failure_message ⇒ Object
22 23 24 |
# File 'lib/dm/matchers/have_many_through.rb', line 22 def "expected to not have many #{@children} through #{@broker}" end |