Class: Oso::Polar::Data::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/oso/polar/data/filter.rb

Overview

Abstract data filter used by the Adapter API.

Defined Under Namespace

Classes: Condition, Projection, Relation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model:, relations:, conditions:, types:) ⇒ Filter

Returns a new instance of Filter.



11
12
13
14
15
16
# File 'lib/oso/polar/data/filter.rb', line 11

def initialize(model:, relations:, conditions:, types:)
  @model = model
  @relations = relations
  @conditions = conditions
  @types = types
end

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions.



9
10
11
# File 'lib/oso/polar/data/filter.rb', line 9

def conditions
  @conditions
end

#modelObject (readonly)

Returns the value of attribute model.



9
10
11
# File 'lib/oso/polar/data/filter.rb', line 9

def model
  @model
end

#relationsObject (readonly)

Returns the value of attribute relations.



9
10
11
# File 'lib/oso/polar/data/filter.rb', line 9

def relations
  @relations
end

#typesObject (readonly)

Returns the value of attribute types.



9
10
11
# File 'lib/oso/polar/data/filter.rb', line 9

def types
  @types
end

Class Method Details

.parse(polar, blob) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oso/polar/data/filter.rb', line 18

def self.parse(polar, blob)
  types = polar.host.types
  model = types[blob['root']].klass.get
  relations = blob['relations'].map do |rel|
    Relation.parse(polar, *rel)
  end
  conditions = blob['conditions'].map do |disj|
    disj.map { |conj| Condition.parse(polar, *conj) }
  end
  new(model: model, relations: relations, conditions: conditions, types: types)
end