Class: CabezaDeTermo::JsonSpec::JsonEach

Inherits:
JsonExpression show all
Defined in:
lib/cabeza-de-termo/json-spec/expressions/json-each.rb

Overview

A JsonExpression that represents what each item in a JsonList must expect.

Instance Method Summary collapse

Methods inherited from JsonExpression

#add_default_expectations, #add_expectation, #add_expectation_from_library, #default_expectations, #default_expectations_for, #expectations_library, #expectations_runner, #is_a_modifier_library_method?, #is_an_expectations_library_method?, #json_spec, #method_missing, #new_any_of_expression, #new_anything_expression, #new_each_field, #new_expectations_runner, #new_expression_for, #new_json_each_expression, #new_json_field_name_expression, #new_list_expression, #new_named_field_expression, #new_object_expression, #new_scalar_expression, #parent_expression, #perform_modifier_from_library, #run_modifier, #set_expectations_runner, #set_parent_expression, #to_be_as_defined_by, #to_be_as_defined_in

Constructor Details

#initialize(parent_expression) ⇒ JsonEach

The expression that holds the expectations of each item in a json list.



13
14
15
16
17
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 13

def initialize(parent_expression)
	super(parent_expression)

	@each_item_expression = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CabezaDeTermo::JsonSpec::JsonExpression

Instance Method Details

#accept_walker(expression_walker) ⇒ Object

Walking expressions



53
54
55
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 53

def accept_walker(expression_walker)
	expression_walker.walk_json_each(self)
end

#each_item_expressionObject



19
20
21
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 19

def each_item_expression()
	@each_item_expression
end

#expect(type, &block) ⇒ Object

Expecting expressions



35
36
37
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 35

def expect(type, &block)
	expect_a(type, &block)
end

#expect_a(type, &block) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 43

def expect_a(type, &block)
	@each_item_expression = new_expression_for(type)

	CdT.bind_block_evaluation_to @each_item_expression, &block unless block.nil?

	@each_item_expression
end

#expect_an(type, &block) ⇒ Object



39
40
41
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 39

def expect_an(type, &block)
	expect_a(type, &block)
end

#has_each_item_expression?Boolean

Asking

Returns:

  • (Boolean)


25
26
27
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 25

def has_each_item_expression?()
	!no_each_item_expression?
end

#no_each_item_expression?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cabeza-de-termo/json-spec/expressions/json-each.rb', line 29

def no_each_item_expression?()
	@each_item_expression.nil?
end