Class: AgnosticBackend::Queryable::Value

Inherits:
TreeNode
  • Object
show all
Defined in:
lib/agnostic_backend/queryable/value.rb

Instance Attribute Summary collapse

Attributes inherited from TreeNode

#children, #context

Instance Method Summary collapse

Methods inherited from TreeNode

#accept

Methods included from Utilities

included

Constructor Details

#initialize(value, parent:, context:) ⇒ Value

Returns a new instance of Value.



8
9
10
11
# File 'lib/agnostic_backend/queryable/value.rb', line 8

def initialize(value, parent:, context:)
  super([], context)
  @value, @parent = value, parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



6
7
8
# File 'lib/agnostic_backend/queryable/value.rb', line 6

def parent
  @parent
end

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/agnostic_backend/queryable/value.rb', line 5

def value
  @value
end

Instance Method Details

#==(o) ⇒ Object



13
14
15
# File 'lib/agnostic_backend/queryable/value.rb', line 13

def ==(o)
  super && o.value == value
end

#associated_attributeObject



17
18
19
# File 'lib/agnostic_backend/queryable/value.rb', line 17

def associated_attribute
  parent.attribute if parent.respond_to? :attribute
end

#typeObject



21
22
23
24
# File 'lib/agnostic_backend/queryable/value.rb', line 21

def type
  return :text if associated_attribute.try(:any?)
  associated_attribute.type if associated_attribute.present?
end