Class: ActiveHarmony::SynchronizerConfiguration
- Inherits:
-
Object
- Object
- ActiveHarmony::SynchronizerConfiguration
- Defined in:
- lib/active_harmony/synchronizer_configuration.rb
Constant Summary collapse
- TYPE_PUSH =
:push- TYPE_PULL =
:pull- TYPE_ALL =
:all
Instance Method Summary collapse
-
#initialize ⇒ SynchronizerConfiguration
constructor
Initializes new Synchronizer Configuration.
-
#pull(field) ⇒ Object
Configures field for pull type of synchronization.
-
#push(field) ⇒ Object
Configures field for push type of synchronization.
-
#synchronizable_for_pull ⇒ Array<Symbol>
Fields that should be synchronized on pull type.
-
#synchronizable_for_push ⇒ Array<Symbol>
Fields that should be synchronized on push type.
-
#synchronizable_for_types(types) ⇒ Array<Symbol>
Fields that should be synchronized on types specified in argument.
-
#synchronize(field, options = {}) ⇒ Object
Configures field for any type of synchronization.
Constructor Details
#initialize ⇒ SynchronizerConfiguration
Initializes new Synchronizer Configuration.
9 10 11 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 9 def initialize @synchronizable_fields = [] end |
Instance Method Details
#pull(field) ⇒ Object
Configures field for pull type of synchronization.
23 24 25 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 23 def pull(field) synchronize field, :type => :pull end |
#push(field) ⇒ Object
Configures field for push type of synchronization.
16 17 18 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 16 def push(field) synchronize field, :type => :push end |
#synchronizable_for_pull ⇒ Array<Symbol>
Fields that should be synchronized on pull type
54 55 56 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 54 def synchronizable_for_pull synchronizable_for_types([TYPE_PULL, TYPE_ALL]) end |
#synchronizable_for_push ⇒ Array<Symbol>
Fields that should be synchronized on push type
47 48 49 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 47 def synchronizable_for_push synchronizable_for_types([TYPE_PUSH, TYPE_ALL]) end |
#synchronizable_for_types(types) ⇒ Array<Symbol>
Fields that should be synchronized on types specified in argument
63 64 65 66 67 68 69 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 63 def synchronizable_for_types(types) @synchronizable_fields.select do |field_description| types.include?(field_description[:type]) end.collect do |field_description| field_description[:field] end end |
#synchronize(field, options = {}) ⇒ Object
Configures field for any type of synchronization. If no type is specified, defaults to TYPE_ALL.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/active_harmony/synchronizer_configuration.rb', line 33 def synchronize(field, = {}) = { :type => TYPE_ALL }.merge() @synchronizable_fields << { :field => field, :type => [:type] } end |