Class: SimpleParams::ValidationMatchers::NestedParameterMatcher
- Inherits:
-
ValidationMatcher
- Object
- Shoulda::Matchers::ActiveModel::ValidationMatcher
- ValidationMatcher
- SimpleParams::ValidationMatchers::NestedParameterMatcher
- Defined in:
- lib/simple_params/validation_matchers/nested_parameter_matcher.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(attribute) ⇒ NestedParameterMatcher
constructor
A new instance of NestedParameterMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ NestedParameterMatcher
Returns a new instance of NestedParameterMatcher.
10 11 12 13 |
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 10 def initialize(attribute) super(attribute) @attribute = attribute end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
8 9 10 |
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 8 def attribute @attribute end |
Instance Method Details
#description ⇒ Object
21 22 23 |
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 21 def description "Should have nested param #{@attribute}" end |
#failure_message_for_should ⇒ Object
25 26 27 |
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 25 def "Should have nested param #{@attribute}" end |
#failure_message_for_should_not ⇒ Object
29 30 31 |
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 29 def "Should not have nested param #{@attribute}" end |
#matches?(subject) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 15 def matches?(subject) super(subject) subject.send(:nested_classes).has_key?(@attribute) && subject.send(:nested_classes)[@attribute.to_sym].hash? end |