Class: BackgroundJobs::Sidekiq::HashAttribute

Inherits:
Hash
  • Object
show all
Defined in:
lib/background_jobs/strategies/sidekiq/job_attributes_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ HashAttribute

Returns a new instance of HashAttribute.



76
77
78
# File 'lib/background_jobs/strategies/sidekiq/job_attributes_adapter.rb', line 76

def initialize(value)
  @value = value
end

Instance Method Details

#decodeObject



89
90
91
92
93
94
95
# File 'lib/background_jobs/strategies/sidekiq/job_attributes_adapter.rb', line 89

def decode
  @value.keys.each do |key|
    @value[key.to_sym] = AttributeFactory.build(@value.delete(key)).decode
  end

  @value
end

#encodeObject



80
81
82
83
84
85
86
87
# File 'lib/background_jobs/strategies/sidekiq/job_attributes_adapter.rb', line 80

def encode
  @value.keys.each do |key|
    value = @value.delete(key)
    @value[key.to_s] = AttributeFactory.build(value).encode
  end
  
  @value
end