Class: CabezaDeTermo::JsonSpec::JsonField
- Inherits:
-
JsonExpression
- Object
- JsonExpression
- CabezaDeTermo::JsonSpec::JsonField
- Defined in:
- lib/cabeza-de-termo/json-spec/expressions/json-field.rb
Overview
A JsonExpression representing an objects field in a json parse tree.
Instance Method Summary collapse
-
#accept_walker(expression_walker) ⇒ Object
Walking expressions.
- #add_expectation(expectation) ⇒ Object
- #default_expectations ⇒ Object
-
#initialize(parent_expression, name) ⇒ JsonField
constructor
A new instance of JsonField.
-
#name ⇒ Object
Accessing.
- #run_modifier(modifier) ⇒ Object
- #set_value_expression(expression) ⇒ Object
-
#to_be(type, &block) ⇒ Object
Expectations.
- #to_be_a(type, &block) ⇒ Object
- #to_be_an(type, &block) ⇒ Object
- #value_expression ⇒ Object
Methods inherited from JsonExpression
#add_default_expectations, #add_expectation_from_library, #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, #set_expectations_runner, #set_parent_expression, #to_be_as_defined_by, #to_be_as_defined_in
Constructor Details
#initialize(parent_expression, name) ⇒ JsonField
Returns a new instance of JsonField.
14 15 16 17 18 19 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 14 def initialize(parent_expression, name) @name = name @value_expression = new_anything_expression super(parent_expression) 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
71 72 73 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 71 def accept_walker(expression_walker) expression_walker.walk_json_field(self) end |
#add_expectation(expectation) ⇒ Object
41 42 43 44 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 41 def add_expectation(expectation) value_expression.add_expectation(expectation) self end |
#default_expectations ⇒ Object
21 22 23 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 21 def default_expectations default_expectations_for(:fields) end |
#name ⇒ Object
Accessing
52 53 54 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 52 def name() @name end |
#run_modifier(modifier) ⇒ Object
46 47 48 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 46 def run_modifier(modifier) value_expression.run_modifier(modifier) end |
#set_value_expression(expression) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 60 def set_value_expression(expression) expression.set_parent_expression(self) @value_expression = expression add_default_expectations expression end |
#to_be(type, &block) ⇒ Object
Expectations
27 28 29 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 27 def to_be(type, &block) to_be_a(type, &block) end |
#to_be_a(type, &block) ⇒ Object
35 36 37 38 39 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 35 def to_be_a(type, &block) expression = set_value_expression( new_expression_for(type) ) CdT.bind_block_evaluation_to expression, &block unless block.nil? expression end |
#to_be_an(type, &block) ⇒ Object
31 32 33 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 31 def to_be_an(type, &block) to_be_a(type, &block) end |
#value_expression ⇒ Object
56 57 58 |
# File 'lib/cabeza-de-termo/json-spec/expressions/json-field.rb', line 56 def value_expression() @value_expression end |