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

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

#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



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_shouldObject



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

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

#failure_message_for_should_notObject



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

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

#matches?(subject) ⇒ Boolean

Returns:

  • (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