Class: Alephant::Broker::Component

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/alephant/broker/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, batch_id, options) ⇒ Component



17
18
19
20
21
22
# File 'lib/alephant/broker/component.rb', line 17

def initialize(id, batch_id, options)
  @id       = id
  @batch_id = batch_id
  @cache    = Cache::Client.new
  @options  = symbolize(options || {})
end

Instance Attribute Details

#batch_idObject (readonly)

Returns the value of attribute batch_id.



15
16
17
# File 'lib/alephant/broker/component.rb', line 15

def batch_id
  @batch_id
end

#contentObject (readonly)

Returns the value of attribute content.



15
16
17
# File 'lib/alephant/broker/component.rb', line 15

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/alephant/broker/component.rb', line 15

def id
  @id
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/alephant/broker/component.rb', line 15

def options
  @options
end

Instance Method Details

#loadObject



24
25
26
27
28
# File 'lib/alephant/broker/component.rb', line 24

def load
  @content ||= @cache.get(cache_key) do
    s3.get(s3_path)
  end
end

#opts_hashObject



30
31
32
# File 'lib/alephant/broker/component.rb', line 30

def opts_hash
  @opts_hash ||= Crimp.signature(options)
end

#versionObject



34
35
36
# File 'lib/alephant/broker/component.rb', line 34

def version
  @version ||= sequencer.get_last_seen
end