Class: AgnosticBackend::Queryable::Attribute

Inherits:
TreeNode
  • Object
show all
Includes:
Utilities
Defined in:
lib/agnostic_backend/queryable/attribute.rb

Instance Attribute Summary collapse

Attributes inherited from TreeNode

#children, #context

Instance Method Summary collapse

Methods included from Utilities

included

Methods inherited from TreeNode

#accept

Constructor Details

#initialize(name, parent:, context:) ⇒ Attribute

Returns a new instance of Attribute.



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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

Instance Method Details

#==(o) ⇒ Object



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

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

#any?Boolean

Returns:

  • (Boolean)


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

def any?
  @name == '*'
end

#score?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/agnostic_backend/queryable/attribute.rb', line 25

def score?
  @name == '_score'
end

#typeObject



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

def type
  value_for_key(context.index.schema, name).try(:type)
end