Class: ReactiveObservers::Observer::Container
- Inherits:
-
Object
- Object
- ReactiveObservers::Observer::Container
- Defined in:
- lib/reactive_observers/observer/container.rb
Instance Attribute Summary collapse
-
#constrain ⇒ Object
Returns the value of attribute constrain.
-
#context ⇒ Object
Returns the value of attribute context.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#notify ⇒ Object
Returns the value of attribute notify.
-
#observed ⇒ Object
Returns the value of attribute observed.
-
#observer ⇒ Object
Returns the value of attribute observer.
-
#on ⇒ Object
Returns the value of attribute on.
-
#only ⇒ Object
Returns the value of attribute only.
-
#refine ⇒ Object
Returns the value of attribute refine.
-
#trigger ⇒ Object
Returns the value of attribute trigger.
-
#trigger_with_previous_values ⇒ Object
Returns the value of attribute trigger_with_previous_values.
Instance Method Summary collapse
- #compare ⇒ Object
-
#initialize(observer, observed, options) ⇒ Container
constructor
A new instance of Container.
- #klass_observed? ⇒ Boolean
- #klass_observer? ⇒ Boolean
- #observed_klass ⇒ Object
- #observer_klass ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(observer, observed, options) ⇒ Container
Returns a new instance of Container.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/reactive_observers/observer/container.rb', line 15 def initialize(observer, observed, ) @observer = observer @observed = observed.is_a?(Symbol) ? observed.to_s.classify.constantize : observed @on = Array.wrap [:on] @fields = Array.wrap [:fields] @only = [:only] @trigger = [:trigger] || ReactiveObservers.configuration.default_trigger @notify = [:notify] @refine = [:refine] @context = [:context] ReactiveObservers::Observer::ContainerValidator.new(self).run_validations! @constrain = load_observer_constrains @trigger_with_previous_values = [:trigger_with_previous_values] || false end |
Instance Attribute Details
#constrain ⇒ Object
Returns the value of attribute constrain.
12 13 14 |
# File 'lib/reactive_observers/observer/container.rb', line 12 def constrain @constrain end |
#context ⇒ Object
Returns the value of attribute context.
11 12 13 |
# File 'lib/reactive_observers/observer/container.rb', line 11 def context @context end |
#fields ⇒ Object
Returns the value of attribute fields.
12 13 14 |
# File 'lib/reactive_observers/observer/container.rb', line 12 def fields @fields end |
#notify ⇒ Object
Returns the value of attribute notify.
11 12 13 |
# File 'lib/reactive_observers/observer/container.rb', line 11 def notify @notify end |
#observed ⇒ Object
Returns the value of attribute observed.
10 11 12 |
# File 'lib/reactive_observers/observer/container.rb', line 10 def observed @observed end |
#observer ⇒ Object
Returns the value of attribute observer.
10 11 12 |
# File 'lib/reactive_observers/observer/container.rb', line 10 def observer @observer end |
#on ⇒ Object
Returns the value of attribute on.
12 13 14 |
# File 'lib/reactive_observers/observer/container.rb', line 12 def on @on end |
#only ⇒ Object
Returns the value of attribute only.
12 13 14 |
# File 'lib/reactive_observers/observer/container.rb', line 12 def only @only end |
#refine ⇒ Object
Returns the value of attribute refine.
11 12 13 |
# File 'lib/reactive_observers/observer/container.rb', line 11 def refine @refine end |
#trigger ⇒ Object
Returns the value of attribute trigger.
11 12 13 |
# File 'lib/reactive_observers/observer/container.rb', line 11 def trigger @trigger end |
#trigger_with_previous_values ⇒ Object
Returns the value of attribute trigger_with_previous_values.
13 14 15 |
# File 'lib/reactive_observers/observer/container.rb', line 13 def trigger_with_previous_values @trigger_with_previous_values end |
Instance Method Details
#compare ⇒ Object
30 31 32 |
# File 'lib/reactive_observers/observer/container.rb', line 30 def compare ReactiveObservers::Observer::ContainerComparator.new(self) end |
#klass_observed? ⇒ Boolean
38 39 40 |
# File 'lib/reactive_observers/observer/container.rb', line 38 def klass_observed? @observed.is_a? Class end |
#klass_observer? ⇒ Boolean
34 35 36 |
# File 'lib/reactive_observers/observer/container.rb', line 34 def klass_observer? @observer.is_a? Class end |
#observed_klass ⇒ Object
48 49 50 51 52 |
# File 'lib/reactive_observers/observer/container.rb', line 48 def observed_klass return @observed if klass_observed? @observed.class end |
#observer_klass ⇒ Object
42 43 44 45 46 |
# File 'lib/reactive_observers/observer/container.rb', line 42 def observer_klass return @observer if klass_observer? @observer.class end |
#to_h ⇒ Object
54 55 56 57 |
# File 'lib/reactive_observers/observer/container.rb', line 54 def to_h { observer: @observer, observed: @observed, fields: @fields, on: @on, only: @only, constrain: @constrain, trigger: @trigger, refine: @refine, notify: @notify, context: @context} end |