Class: SimpleParams::ValidationMatchers::NestedParameterMatcher

Inherits:
ValidationMatcher
  • Object
show all
Defined in:
lib/simple_params/validation_matchers/nested_parameter_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ 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

#attributeObject

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

#descriptionObject



20
21
22
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 20

def description
  "Should have nested param #{@attribute}"
end

#failure_message_for_shouldObject



24
25
26
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 24

def failure_message_for_should
  "Should have nested param #{@attribute}"
end

#failure_message_for_should_notObject



28
29
30
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 28

def failure_message_for_should_not
  "Should not have nested param #{@attribute}"
end

#matches?(subject) ⇒ Boolean



15
16
17
18
# File 'lib/simple_params/validation_matchers/nested_parameter_matcher.rb', line 15

def matches?(subject)
  super(subject)
  subject.send(:nested_hashes).has_key?(@attribute)
end