Class: Noiseless::AST::Node
- Inherits:
-
Object
- Object
- Noiseless::AST::Node
- Defined in:
- lib/noiseless/ast.rb
Direct Known Subclasses
Aggregation, Bool, Bulk, Collapse, CombinedFields, Conversation, FieldValueNode, Hybrid, ImageQuery, Join, Paginate, Range, Root, SearchAfter, Sort, Vector
Instance Method Summary collapse
- #to_h ⇒ Object (also: #to_hash)
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/noiseless/ast.rb', line 6 def to_h hash = {} instance_variables.each do |var| key = var.to_s.delete("@").to_sym value = instance_variable_get(var) hash[key] = case value when Node value.to_h when Array value.map { |item| item.is_a?(Node) ? item.to_h : item } else value end end # Include the class name for better introspection hash[:_type] = self.class.name.split("::").last hash end |