Class: PubSubModelSync::Subscriber

Inherits:
Base
  • Object
show all
Defined in:
lib/pub_sub_model_sync/subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

config, debug?, log

Constructor Details

#initialize(klass, action, mapping: [], settings: {}) ⇒ Subscriber

Returns a new instance of Subscriber.

Parameters:

  • klass (String)

    class name

  • action (Symbol)

    @refer SubscriberConcern.ps_subscribe

  • mapping (Array<String>) (defaults to: [])

    @refer SubscriberConcern.ps_subscribe

  • settings (Hash) (defaults to: {})

    : @refer SubscriberConcern.ps_subscribe



12
13
14
15
16
17
18
19
20
# File 'lib/pub_sub_model_sync/subscriber.rb', line 12

def initialize(klass, action, mapping: [], settings: {})
  def_settings = { from_klass: klass, to_action: action, id: :id, if: nil, unless: nil, mode: :model }
  @klass = klass
  @mapping = mapping
  @settings = def_settings.merge(settings)
  @action = action.to_sym
  @from_klass = @settings[:from_klass].to_s
  @mode = @settings[:mode].to_sym
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



5
6
7
# File 'lib/pub_sub_model_sync/subscriber.rb', line 5

def action
  @action
end

#from_klassObject

Returns the value of attribute from_klass.



5
6
7
# File 'lib/pub_sub_model_sync/subscriber.rb', line 5

def from_klass
  @from_klass
end

#klassObject

Returns the value of attribute klass.



5
6
7
# File 'lib/pub_sub_model_sync/subscriber.rb', line 5

def klass
  @klass
end

#mappingObject

Returns the value of attribute mapping.



5
6
7
# File 'lib/pub_sub_model_sync/subscriber.rb', line 5

def mapping
  @mapping
end

#modeObject

Returns the value of attribute mode.



5
6
7
# File 'lib/pub_sub_model_sync/subscriber.rb', line 5

def mode
  @mode
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/pub_sub_model_sync/subscriber.rb', line 6

def model
  @model
end

#payloadObject (readonly)

Returns the value of attribute payload.



6
7
8
# File 'lib/pub_sub_model_sync/subscriber.rb', line 6

def payload
  @payload
end

#settingsObject

Returns the value of attribute settings.



5
6
7
# File 'lib/pub_sub_model_sync/subscriber.rb', line 5

def settings
  @settings
end