Class: ReactiveObservers::Observer::ContainerComparator

Inherits:
Object
  • Object
show all
Defined in:
lib/reactive_observers/observer/container_comparator.rb

Instance Method Summary collapse

Constructor Details

#initialize(observer) ⇒ ContainerComparator

Returns a new instance of ContainerComparator.



6
7
8
# File 'lib/reactive_observers/observer/container_comparator.rb', line 6

def initialize(observer)
  @observer = observer
end

Instance Method Details

#full?(observer) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/reactive_observers/observer/container_comparator.rb', line 18

def full?(observer)
  partial?(observer.observer, fields: observer.fields, on: observer.on, constrain: observer.constrain) &&
    @observer.observed == observer.observed &&
    @observer.trigger == observer.trigger &&
    @observer.notify == observer.notify &&
    @observer.refine == observer.refine &&
    @observer.only == observer.only
end

#partial?(observer, options) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/reactive_observers/observer/container_comparator.rb', line 10

def partial?(observer, options)
  @observer.observer == observer &&
    array_compare_of(@observer.fields, options[:fields]) &&
    array_compare_of(@observer.on, options[:on]) &&
    context_compare_with(options[:context]) &&
    constrain_compare_with(options[:constrain])
end